快捷方式

SpeedPerturbation

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

应用 *Audio augmentation for speech recognition* [Ko 等人,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]][源代码]
参数:
  • 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 开发者文档

查看文档

教程

获取针对初学者和高级开发者的深度教程

查看教程

资源

查找开发资源并获得问题解答

查看资源