Waveform level augmentations.

Individual implementations of Augmentation are callables that accept the signal to augment as an argument and return the augmented signal.

Augmentation parameters can be Constant, or random with Normal or Uniform distribution. Random parameters will be sampled from a given distribution anew for each augmentation.

aug = Gain(gain=Normal(mean=1, std=0.5)); augmented_signal = aug(signal)

class das.augmentation.Augmentation[source]

Base class for all augmentations.

Augmentations are callables that return the augmented input. Can optionally pass through a second input.

class das.augmentation.Augmentations(augmentations: List[das.augmentation.Augmentation])[source]

Bundles several augmentations.


augmentations (List[Augmentation]) – List of augmentations.

class das.augmentation.CircShift(shift: das.augmentation.Param)[source]

Circularly shift input along the first axis.


shift (Param) – Amount of shift, in samples.

class das.augmentation.Constant(value: float = 0.0)[source]

Constant parameter.


value (float, optional) – Constant parameter value. Defaults to 0.0.

class das.augmentation.Gain(gain: das.augmentation.Param)[source]

Multiply signal with gain factor.


gain (Param) – Gain.

class das.augmentation.HorizontalFlip(flip: das.augmentation.Param)[source]

Horizontally flip signal.


flip (Param) – Signal is flipped if >0.

class das.augmentation.MaskMean(duration: das.augmentation.Param)[source]

Replaces stretch of duration samples with mean over that stretch.


duration (Param) – Duration of the stretch, in samples.

class das.augmentation.MaskNoise(std: Optional[das.augmentation.Param] = None, mean: Optional[das.augmentation.Param] = None, duration: Optional[das.augmentation.Param] = None, add: bool = True)[source]

Add noise or replace signal by noise for the full duration or a part of it.

  • std (Optional[Param]) – std of noise. Defaults to 1.

  • mean (Optional[Param]) – mean of noise. Defaults to 0.

  • duration (Optional[Param]) – nb_samples, Optional. If omitted will mask full duration.

  • add (bool) – add or replace. Defaults to True.

class das.augmentation.Normal(mean: float = 0.0, std: float = 1.0)[source]

Normally distributed parameter.

  • mean (float, optional) – Mean of the Normal pdf. Defaults to 0.0.

  • std (float, optional) – Standerd deviation of the Normal pdf. Defaults to 1.0.

class das.augmentation.Offset(offset: das.augmentation.Param)[source]

Add horizontal offset.


offset (Param) – Offset.

class das.augmentation.Param[source]

Base class for all parameters.

Parameters are callables that return parameter values.

class das.augmentation.Uniform(lower: float = - 1.0, upper: float = 1.0)[source]

Uniformly distributed parameter.

  • lower (float, optional) – Lower bound. Defaults to -1.0.

  • upper (float, optional) – Upper bound. Defaults to 1.0.

class das.augmentation.Upsampling(factor: das.augmentation.Param)[source]

Upsample signal.


factor (Param) – Upsampling factor.


ValueError – if ‘lower’ attr of factor is <1 (would correspond to downsampling).