- class torchaudio.transforms.SpeedPerturbation(orig_freq: int, factors: Sequence[float])¶
Applies the speed perturbation augmentation introduced in Audio augmentation for speech recognition [Ko et al., 2015]. For a given input, the module samples a speed-up factor from
factorsuniformly at random and adjusts the speed of the input by that factor.
>>> speed_perturb = SpeedPerturbation(16000, [0.9, 1.1, 1.0, 1.0, 1.0]) >>> # waveform speed will be adjusted by factor 0.9 with 20% probability, >>> # 1.1 with 20% probability, and 1.0 (i.e. kept the same) with 60% probability. >>> speed_perturbed_waveform = speed_perturb(waveform, lengths)
- forward(waveform: Tensor, lengths: Optional[Tensor] = None) Tuple[Tensor, Optional[Tensor]] ¶
Speed-adjusted waveform, with shape (…, new_time).
- torch.Tensor or None
None, valid lengths of signals in speed-adjusted waveform, with shape (…); otherwise,
- Return type: