Shortcuts

Speed

class torchaudio.transforms.Speed(orig_freq, factor)[source]

Adjusts waveform speed.

This feature supports the following devices: CPU, CUDA This API supports the following properties: Autograd, TorchScript
Parameters:
  • orig_freq (int) – Original frequency of the signals in waveform.

  • factor (float) – Factor by which to adjust speed of input. Values greater than 1.0 compress waveform in time, whereas values less than 1.0 stretch waveform in time.

forward(waveform, lengths: Optional[Tensor] = None) Tuple[Tensor, Optional[Tensor]][source]
Parameters:
  • waveform (torch.Tensor) – Input signals, with shape (…, time).

  • lengths (torch.Tensor or None, optional) – Valid lengths of signals in waveform, with shape (…). If None, all elements in waveform are treated as valid. (Default: None)

Returns:

torch.Tensor

Speed-adjusted waveform, with shape (…, new_time).

torch.Tensor or None

If lengths is not None, valid lengths of signals in speed-adjusted waveform, with shape (…); otherwise, None.

Return type:

(torch.Tensor, torch.Tensor or None)

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