Shortcuts

torchaudio.functional.pitch_shift

torchaudio.functional.pitch_shift(waveform: Tensor, sample_rate: int, n_steps: int, bins_per_octave: int = 12, n_fft: int = 512, win_length: Optional[int] = None, hop_length: Optional[int] = None, window: Optional[Tensor] = None) Tensor[source]

Shift the pitch of a waveform by n_steps steps.

This feature supports the following devices: CPU, CUDA This API supports the following properties: TorchScript
Parameters:
  • waveform (Tensor) – The input waveform of shape (…, time).

  • sample_rate (int) – Sample rate of waveform.

  • n_steps (int) – The (fractional) steps to shift waveform.

  • bins_per_octave (int, optional) – The number of steps per octave (Default: 12).

  • n_fft (int, optional) – Size of FFT, creates n_fft // 2 + 1 bins (Default: 512).

  • win_length (int or None, optional) – Window size. If None, then n_fft is used. (Default: None).

  • hop_length (int or None, optional) – Length of hop between STFT windows. If None, then win_length // 4 is used (Default: None).

  • window (Tensor or None, optional) – Window tensor that is applied/multiplied to each frame/window. If None, then torch.hann_window(win_length) is used (Default: None).

Returns:

The pitch-shifted audio waveform of shape (…, time).

Return type:

Tensor

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources