nlpaug.augmenter.audio.shift

Augmenter that apply shifting operation to audio.

class nlpaug.augmenter.audio.shift.ShiftAug(sampling_rate, duration=3, direction='random', shift_direction='random', name='Shift_Aug', verbose=0, stateless=True)[source]

Bases: nlpaug.augmenter.audio.audio_augmenter.AudioAugmenter

Parameters:
  • sampling_rate (int) – Sampling rate of input audio.
  • duration (float) – Max shifting segment (in second)
  • direction (str) – Shifting segment to left, right or one of them. Value can be ‘left’, ‘right’ or ‘random’
  • name (str) – Name of this augmenter
>>> import nlpaug.augmenter.audio as naa
>>> aug = naa.ShiftAug(sampling_rate=44010)
augment(data, n=1, num_thread=1)
Parameters:
  • data (object/list) – Data for augmentation. It can be list of data (e.g. list of string or numpy) or single element (e.g. string or numpy). Numpy format only supports audio or spectrogram data. For text data, only support string or list of string.
  • n (int) – Default is 1. Number of unique augmented output. Will be force to 1 if input is list of data
  • num_thread (int) – Number of thread for data augmentation. Use this option when you are using CPU and n is larger than 1
Returns:

Augmented data

>>> augmented_data = aug.augment(data)