I/O functionalities

Audio I/O functions are implemented in torchaudio.backend module, but for the ease of use, the following functions are made available on torchaudio module. There are different backends available and you can switch backends with set_audio_backend().

Please refer to torchaudio.backend for the detail, and the Audio I/O tutorial for the usage. str, ...)

Fetch meta data of an audio file. Refer to torchaudio.backend for the detail.

torchaudio.load(filepath: str, ...)

Load audio file into torch.Tensor object. Refer to torchaudio.backend for the detail. str, src: torch.Tensor, sample_rate: int, ...)

Save torch.Tensor object into an audio format. Refer to torchaudio.backend for the detail.

Backend Utilities

torchaudio.list_audio_backends() List[str][source]

List available backends


The list of available backends.

Return type:


torchaudio.get_audio_backend() Optional[str][source]

Get the name of the current backend


The name of the current backend or None if no backend is assigned.

Return type:


torchaudio.set_audio_backend(backend: Optional[str])[source]

Set the backend for I/O operation


backend (str or None) – Name of the backend. One of "sox_io" or "soundfile" based on availability of the system. If None is provided the current backend is unassigned.


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources