예제 #1
0
def apply_effects_sox(audio_signal, filters):
    """
    apply_effects_sox takes an AudioSignal object and a list of SoXFilter objects
    and sequentially applies each filter to the signal. 
    Args:
        audio_signal (AudioSignal): AudioSignal object
        filters (list): List of SoXFilter objects
    Returns:
        augmented_signal (AudioSignal): A new AudioSignal object, with the audio data from 
        audio_signal after applying filters
    """
    # lazy load to avoid circular import
    from . import AudioSignal

    audio_data = audio_signal.audio_data

    tfm = sox.Transformer()
    for filter_ in filters:
        tfm = filter_(tfm)
    augmented_data = tfm.build_array(input_array=audio_data.T,
                                     sample_rate_in=audio_signal.sample_rate)

    augmented_signal = audio_signal.make_copy_with_audio_data(augmented_data)
    augmented_signal._effects_applied += filters
    return augmented_signal
예제 #2
0
 def do_transform(y):
     tfm = sox.Transformer()
     tfm.vol(0.5)
     y_out = tfm.build_array(input_array=y, sample_rate_in=1000)
     return y_out
예제 #3
0
import soxbindings as sox
import sys

# python demo.py tests/data/input.wav
# create transformer
tfm = sox.Transformer()
# trim the audio between 5 and 10.5 seconds.
tfm.trim(5, 10.5)
# apply compression
tfm.compand()
# apply a fade in and fade out
tfm.fade(fade_in_len=1.0, fade_out_len=0.5)
# create an output file.
tfm.build_file(sys.argv[-1], 'demo_output.wav')
def load_soxbindings(fp):
    tfm = soxbindings.Transformer()
    array_out = tfm.build_array(input_filepath=fp)
    return array_out