espnet2.layers.augmentation.speed_perturb
Less than 1 minute
espnet2.layers.augmentation.speed_perturb
espnet2.layers.augmentation.speed_perturb(waveform, sample_rate: int, factor: float)
Speed perturbation which also changes the pitch.
Note: This function should be used with caution as it changes the signal duration.
- Parameters:
- waveform (torch.Tensor) – audio signal (…, time).
- sample_rate (int) – sampling rate in Hz.
- factor (float) – speed factor (e.g., 0.9 for 90% speed).
- Returns: perturbed signal (…, time).
- Return type: ret (torch.Tensor)
Examples
>>> import torch
>>> waveform = torch.randn(16000) # Example waveform of 1 second
>>> sample_rate = 16000
>>> perturbed_waveform = speed_perturb(waveform, sample_rate, factor=0.9)
>>> perturbed_waveform.shape
torch.Size([14400]) # Duration will be shorter due to speed perturbation