快捷鍵

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)[原始碼]

將波形的音調移動 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, optional) – 每個八度的步數 (預設:12)。

  • n_fft (int, optional) – FFT 大小,建立 n_fft // 2 + 1 個頻率箱 (預設:512)。

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

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

  • window (TensorNone, optional) – 套用/乘到每個影格/視窗的視窗張量。如果為 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)[原始碼]

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

當執行參數形狀推斷時,這新增了一個介面,將參數初始化與前向傳遞隔離。

forward(waveform: Tensor) Tensor[原始碼]
參數:

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

返回:

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

返回類型:

Tensor

文件

存取 PyTorch 的完整開發者文件

查看文件

教學

取得適用於初學者和進階開發者的深入教學

查看教學

資源

尋找開發資源並獲得問題解答

查看資源