Shortcuts

torchaudio

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().

Refer to torchaudio.backend for the detail.

torchaudio.info(filepath: 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.

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

Load audio file into torch.Tensor, Refer to torchaudio.backend for the detail.

torchaudio.save(filepath: 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

Returns

The list of available backends.

Return type

List[str]

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

Get the name of the current backend

Returns

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

Return type

Optional[str]

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

Set the backend for I/O operation

Parameters

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

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