速度扰动¶
- class torchaudio.transforms.SpeedPerturbation(orig_freq: int, factors: Sequence[float])[source]¶
应用在语音识别音频增强中介绍的速度扰动增强[Ko et al., 2015]。对于给定的输入,该模块从
factors
中均匀随机采样一个加速因子,并根据该因子调整输入的速度。- 参数:
- 示例
>>> 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]] [source]¶
- 参数:
waveform (torch.Tensor) – 输入信号,形状为(…, time)。
lengths (torch.Tensor or None, optional) –
waveform
中信号的有效长度,形状为(…)。如果为None
,则将waveform
中的所有元素视为有效。(默认:None
)
- 返回:
- torch.Tensor
速度调整后的波形,形状为(…, new_time)。
- torch.Tensor 或 None
如果
lengths
不为None
,则速度调整后的波形中信号的有效长度,形状为(…);否则为None
。
- 返回类型:
(torch.Tensor, torch.Tensor or None)