快捷方式

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 開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源