快捷方式

PitchShift

class torchaudio.transforms.PitchShift(sample_rate: int, n_steps:: int, bins_per_octave: int = 12, n_fft: int = 512, win_length: ~typing.Optional[int] = None, hop_length: ~typing.Optional[int] = None, window_fn: ~typing.Callable[[...], ~torch.Tensor] = <built-in method hann_window of type object>, wkwargs: ~typing.Optional[dict] = None)[source]

將波形音高移動 n_steps 步。

This feature supports the following devices: CPU, CUDA This API supports the following properties: TorchScript
引數:
  • waveform (Tensor) – 輸入波形,形狀為 (…, time)

  • sample_rate (int) – 波形的取樣率 waveform

  • n_steps (int) – 移動波形 waveform 的(分數)步數。

  • bins_per_octave (int, 可選) – 每倍頻程的步數(預設值:12)。

  • n_fft (int, 可選) – FFT 大小,建立 n_fft // 2 + 1 個 bin(預設值:512)。

  • win_length (intNone, 可選) – 視窗大小。如果為 None,則使用 n_fft。(預設值:None)。

  • hop_length (intNone, 可選) – STFT 視窗之間的跳躍長度。如果為 None,則使用 win_length // 4(預設值:None)。

  • window (TensorNone, 可選) – 應用/乘以每個幀/視窗的視窗張量。如果為 None,則使用 torch.hann_window(win_length)(預設值:None)。

示例
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
>>> transform = transforms.PitchShift(sample_rate, 4)
>>> waveform_shift = transform(waveform)  # (channel, time)
initialize_parameters(input)[source]

根據輸入批次的屬性初始化引數。

這增加了一個介面,用於在進行引數形狀推斷時將引數初始化與前向傳播隔離開來。

forward(waveform: Tensor) Tensor[source]
引數:

waveform (Tensor) – 維度為 (…, time) 的音訊張量。

返回:

音高已移動的音訊,形狀為 (…, time)

返回型別:

Tensor

文件

訪問 PyTorch 的綜合開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

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

檢視資源