audaugio.augmentation package

Module contents

class audaugio.augmentation.AugmentationBase(replaces: bool, *kwargs)[source]

Base class for an augmentation. Implement this to create your own augmentations.

Parameters:replaces – whether the augmentation should replace the audio it augments. Usually will be false.
augment(signal, sr)[source]

Given a signal, apply the augmentation and return all resulting augmented audio as a list (even if it’s a single signal).

Parameters:
  • signal – unaugmented signal, ndarray
  • sr – sample rate, int
class audaugio.augmentation.BackgroundNoiseAugmentation(amplitude)[source]

Add background noise randomly sampled from a 0-centered normal distribution.

augment(signal, sr)[source]

Given a signal, apply the augmentation and return all resulting augmented audio as a list (even if it’s a single signal).

Parameters:
  • signal – unaugmented signal, ndarray
  • sr – sample rate, int
class audaugio.augmentation.EqualizerAugmentation(frequency: float, resonance: float, gain: float)[source]

Add an arbitrarily tall and wide frequency filter at an arbitrary frequency.

Parameters:
  • frequency – center of the filter
  • resonance – width of the filter as a q-factor
  • gain – height of the filter in dB
class audaugio.augmentation.PitchShiftAugmentation(steps)[source]

Pitch shift a signal by half-steps without changing the duration.

augment(signal, sr)[source]

Given a signal, apply the augmentation and return all resulting augmented audio as a list (even if it’s a single signal).

Parameters:
  • signal – unaugmented signal, ndarray
  • sr – sample rate, int
class audaugio.augmentation.TimeStretchAugmentation(rate)[source]

Change the duration of a signal without changing its pitch.

Parameters:rate – factor by which to speed up or slow down the signal. When rate is 1, the signal is not modified.
augment(signal, sr)[source]

Given a signal, apply the augmentation and return all resulting augmented audio as a list (even if it’s a single signal).

Parameters:
  • signal – unaugmented signal, ndarray
  • sr – sample rate, int
class audaugio.augmentation.WindowingAugmentation(window_length: float, hop_size: float, drop_last=False)[source]

Window a signal into many segments of equal length. If hop_size is less than window_length, these windows will overlap.

Parameters:
  • window_length – the length in seconds of a window
  • hop_size – the distance in seconds between the start of each window
  • drop_last – whether to zero-pad the last segment of audio when it is shorter than window_length. If false, this part of the signal is dropped.
augment(signal, sr)[source]

Given a signal, apply the augmentation and return all resulting augmented audio as a list (even if it’s a single signal).

Parameters:
  • signal – unaugmented signal, ndarray
  • sr – sample rate, int
class audaugio.augmentation.LowPassAugmentation(frequency: float, resonance: float, n_poles: int = 1)[source]

Filter out high frequencies.

Parameters:
  • frequency – center of the filter
  • resonance – width of the filter as a q-factor. Only applies when n_poles = 2.
  • n_poles – either 1 or 2. Number of poles in the filter.
class audaugio.augmentation.HighPassAugmentation(frequency: float, resonance: float, n_poles: int = 1)[source]

Filter out low frequencies.

Parameters:
  • frequency – center of the filter
  • resonance – width of the filter as a q-factor. Only applies when n_poles = 2.
  • n_poles – either 1 or 2. Number of poles in the filter.