Shortcuts

play_audio

class torchaudio.io.play_audio(waveform: Tensor, sample_rate: Optional[float], device: Optional[str] = None)[source]

Plays audio through specified or available output device.

Warning

This function is currently only supported on MacOS, and requires libavdevice (FFmpeg) with audiotoolbox output device.

Note

This function can play up to two audio channels.

Parameters:
  • waveform – Tensor containing the audio to play. Expected shape: (time, num_channels).

  • sample_rate – Sample rate of the audio to play.

  • device – Output device to use. If None, the default device is used.

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