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步。- 引數:
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 (int 或 None, 可選) – 視窗大小。如果為 None,則使用
n_fft。(預設值:None)。hop_length (int 或 None, 可選) – STFT 視窗之間的跳躍長度。如果為 None,則使用
win_length // 4(預設值:None)。window (Tensor 或 None, 可選) – 應用/乘以每個幀/視窗的視窗張量。如果為 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)