快捷链接

SpeedPerturbation

class torchaudio.transforms.SpeedPerturbation(orig_freq: int, factors: Sequence[float])[source]

应用在语音识别的音频增强 [Ko et al., 2015] 中引入的速度扰动增强。对于给定的输入,该模块从 factors 中均匀随机采样一个加速因子,并按该因子调整输入的速度。

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript
参数:
  • orig_freq (int) – waveform 中信号的原始频率。

  • factors (Sequence[float]) – 用于调整输入速度的因子。大于 1.0 的值压缩 waveform 的时间,而小于 1.0 的值拉伸 waveform 的时间。

示例
>>> 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.TensorNone, 可选) – waveform 中信号的有效长度,形状为 (…)。如果为 None,则 waveform 中的所有元素都将被视为有效。(默认值:None

返回:

torch.Tensor

速度调整后的波形,形状为 (…, new_time)

torch.Tensor 或 None

如果 lengths 不为 None,则为速度调整后的波形中信号的有效长度,形状为 (…);否则为 None

返回类型:

(torch.Tensor, torch.Tensor 或 None)

文档

访问 PyTorch 的全面开发者文档

查看文档

教程

获取面向初学者和高级开发者的深入教程

查看教程

资源

查找开发资源并获得解答

查看资源