Shortcuts

play_audio

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

DEPRECATED

Warning

This function has been deprecated. It will be removed from 2.9 release. This deprecation is part of a large refactoring effort to transition TorchAudio into a maintenance phase. The decoding and encoding capabilities of PyTorch for both audio and video are being consolidated into TorchCodec. Please see https://github.com/pytorch/audio/issues/3902 for more information.

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