torchaudio has no attribute 'info' (fix)
torchaudio.info(path) raises AttributeError: module 'torchaudio' has no attribute 'info' on torchaudio 2.9 and newer. Tested fixes: read metadata with soundfile.info, or pin torch==2.8.0 and torchaudio==2.8.0.
1. The error
A one-second test file made with the standard library:
import math, struct, wave
with wave.open("tone.wav", "wb") as w: # 1 s, 16 kHz, mono 440 Hz
w.setnchannels(1); w.setsampwidth(2); w.setframerate(16000)
w.writeframes(b"".join(struct.pack("<h", int(8000 * math.sin(2 * math.pi * 440 * i / 16000))) for i in range(16000)))
print("wrote tone.wav")
wrote tone.wav
On torch and torchaudio 2.9.0:
import torchaudio
print("torchaudio", torchaudio.__version__)
info = torchaudio.info("tone.wav")
Traceback (most recent call last):
File "/tmp/ti442/b1.py", line 3, in <module>
info = torchaudio.info("tone.wav")
^^^^^^^^^^^^^^^
AttributeError: module 'torchaudio' has no attribute 'info'
In our test torchaudio 2.9.0 still has load and save, but info, AudioMetaData and list_audio_backends are gone. On 2.8.0 all of them exist.
2. Fix: read the metadata with soundfile
pip install soundfile (it ships libsndfile in its wheels):
import soundfile as sf
info = sf.info("tone.wav")
print(info.samplerate, info.frames, info.channels, info.duration)
16000 16000 1 1.0
Field names differ: samplerate, frames, channels instead of torchaudio's sample_rate, num_frames, num_channels.
3. Fix: pin torch and torchaudio to 2.8.0
If the call is inside a library you can't edit:
pip install "torch==2.8.0" "torchaudio==2.8.0"
import torchaudio
print("torchaudio", torchaudio.__version__)
info = torchaudio.info("tone.wav")
print(info.sample_rate, info.num_frames, info.num_channels)
torchaudio 2.8.0+cpu
/tmp/ti442/b5.py:3: UserWarning: torchaudio._backend.utils.info has been deprecated. 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. It will be removed from the 2.9 release.
info = torchaudio.info("tone.wav")
.../site-packages/torchaudio/_backend/soundfile_backend.py:120: UserWarning: torchaudio._backend.common.AudioMetaData has been deprecated. 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. It will be removed from the 2.9 release.
return AudioMetaData(
16000 16000 1
It works, with deprecation warnings announcing the removal.
Also: torchaudio.load may fail next
On 2.9.0, torchaudio.load still exists but decodes through TorchCodec. On our box (no FFmpeg installed, torchcodec 0.17.0) it failed:
import torchaudio
waveform, sr = torchaudio.load("tone.wav")
print(waveform.shape, sr)
Traceback (most recent call last):
...
OSError: Could not load this library: .../site-packages/torchcodec/libtorchcodec_image.so
Install FFmpeg for TorchCodec, or load with soundfile and convert to the same (channels, frames) tensor layout:
import soundfile as sf, torch
data, sr = sf.read("tone.wav", dtype="float32", always_2d=True)
waveform = torch.from_numpy(data.T) # (channels, frames), like torchaudio.load
print(waveform.shape, sr)
torch.Size([1, 16000]) 16000
Related: torchaudio has no attribute AudioMetaData (pyannote.audio 3.x) · Could not load libtorchcodec (FFmpeg / version mismatch) · No module named torchaudio.backend · No module named torchaudio.io · libtorchaudio.so undefined symbol
Frequently asked questions
Which torchaudio version removed info?
In our test torchaudio.info exists on 2.8.0 (with a deprecation warning) and is gone on 2.9.0.
Does torchaudio.load still work on 2.9?
It exists but decodes through TorchCodec, which needs FFmpeg; without it our test raised OSError. soundfile.read loaded our WAV test file into the same tensor shape.
Written with AI assistance. Measured on 2026-10-24 on Linux with CPython 3.11.17, CPU wheels of torch/torchaudio 2.8.0 and 2.9.0, soundfile 0.14.0. Output pasted unedited except shortened site-packages paths and cut tracebacks. PlainTables is our extension; torchaudio and soundfile are free.