nlpaug.augmenter.audio.noise

Augmenter that apply noise injection operation to audio.

class nlpaug.augmenter.audio.noise.NoiseAug(zone=(0.2, 0.8), coverage=1.0, color='white', noises=None, name='Noise_Aug', verbose=0, stateless=True)[source]

Bases: nlpaug.augmenter.audio.audio_augmenter.AudioAugmenter

Parameters:
  • zone (tuple) – Assign a zone for augmentation. Default value is (0.2, 0.8) which means that no any augmentation will be applied in first 20% and last 20% of whole audio.
  • coverage (float) – Portion of augmentation. Value should be between 0 and 1. If 1 is assigned, augment operation will be applied to target audio segment. For example, the audio duration is 60 seconds while zone and coverage are (0.2, 0.8) and 0.7 respectively. 42 seconds ((0.8-0.2)*0.7*60) audio will be augmented.
  • color (str) – Colors of noise. Supported ‘white’, ‘pink’, ‘red’, ‘brown’, ‘brownian’, ‘blue’, ‘azure’, ‘violet’, ‘purple’ and ‘random’. If ‘random’ is used, noise color will be picked randomly in each augment.
  • noises (list) – Background noises for noise injection. You can provide more than one background noise and noise will be picked randomly. Expected format is list of numpy array. If this value is provided. color value will be ignored
  • name (str) – Name of this augmenter
>>> import nlpaug.augmenter.audio as naa
>>> aug = naa.NoiseAug()
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)