Shortcuts

torchaudio.functional.phase_vocoder

torchaudio.functional.phase_vocoder(complex_specgrams: Tensor, rate: float, phase_advance: Tensor) Tensor[source]

Given a STFT tensor, speed up in time without modifying pitch by a factor of rate.

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript
Parameters:
  • complex_specgrams (Tensor) – A tensor of dimension (…, freq, num_frame) with complex dtype.

  • rate (float) – Speed-up factor

  • phase_advance (Tensor) – Expected phase advance in each bin. Dimension of (freq, 1)

Returns:

Stretched spectrogram. The resulting tensor is of the same dtype as the input spectrogram, but the number of frames is changed to ceil(num_frame / rate).

Return type:

Tensor

Example
>>> freq, hop_length = 1025, 512
>>> # (channel, freq, time)
>>> complex_specgrams = torch.randn(2, freq, 300, dtype=torch.cfloat)
>>> rate = 1.3 # Speed up by 30%
>>> phase_advance = torch.linspace(
>>>    0, math.pi * hop_length, freq)[..., None]
>>> x = phase_vocoder(complex_specgrams, rate, phase_advance)
>>> x.shape # with 231 == ceil(300 / 1.3)
torch.Size([2, 1025, 231])

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