torchaudio has no attribute 'AudioMetaData' (fix)
from pyannote.audio import Pipeline fails with AttributeError: module 'torchaudio' has no attribute 'AudioMetaData' when pyannote.audio 3.x meets torchaudio 2.9 or newer. Tested fixes: pin torch==2.8.0 and torchaudio==2.8.0, or upgrade to pyannote.audio 4.
1. The error
A fresh environment with pyannote.audio 3.3.2. Its metadata requires only torchaudio>=2.2.0, so pip is free to pick torchaudio 2.9 or newer. We pinned 2.9.0 to show the first failing release:
pip install "pyannote.audio==3.3.2" "torch==2.9.0" "torchaudio==2.9.0"
import torch, torchaudio, pyannote.audio
print("torch", torch.__version__, "| torchaudio", torchaudio.__version__, "| pyannote.audio", pyannote.audio.__version__)
from pyannote.audio import Model, Pipeline
print("import OK")
Traceback (most recent call last):
...
from .core.inference import Inference
File ".../site-packages/pyannote/audio/core/inference.py", line 35, in <module>
from pyannote.audio.core.io import AudioFile
File ".../site-packages/pyannote/audio/core/io.py", line 60, in <module>
) -> torchaudio.AudioMetaData:
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'torchaudio' has no attribute 'AudioMetaData'
pyannote.audio 3.x uses torchaudio.AudioMetaData as a type hint in pyannote/audio/core/io.py, so the import itself fails before any model is loaded. In our test hasattr(torchaudio, "AudioMetaData") is True on torchaudio 2.8.0 and False on 2.9.0.
2. Fix: pin torch and torchaudio to 2.8
Keep pyannote.audio 3.x and pin the pair together (torch and torchaudio versions must match):
pip install "pyannote.audio==3.3.2" "torch==2.8.0" "torchaudio==2.8.0"
import torch, torchaudio, pyannote.audio
print("torch", torch.__version__, "| torchaudio", torchaudio.__version__, "| pyannote.audio", pyannote.audio.__version__)
from pyannote.audio import Model, Pipeline
print("import OK")
.../site-packages/pyannote/audio/core/io.py:212: UserWarning: torchaudio._backend.list_audio_backends 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.
torchaudio.list_audio_backends()
torch 2.8.0+cpu | torchaudio 2.8.0+cpu | pyannote.audio 3.3.2
import OK
The import works; the deprecation warning is torchaudio announcing the same refactor.
3. Fix: upgrade to pyannote.audio 4
pyannote.audio 4.x dropped the old torchaudio I/O and depends on torchcodec. On torch 2.9.0:
pip install "pyannote.audio==4.0.7"
import torch, torchaudio, pyannote.audio
print("torch", torch.__version__, "| torchaudio", torchaudio.__version__, "| pyannote.audio", pyannote.audio.__version__)
from pyannote.audio import Model, Pipeline
print("import OK")
.../site-packages/pyannote/audio/core/io.py:48: UserWarning:
torchcodec is not installed correctly so built-in audio decoding will fail. Solutions are:
* use audio preloaded in-memory as a {'waveform': (channel, time) torch.Tensor, 'sample_rate': int} dictionary;
* fix torchcodec installation. Error message was:
Could not load this library: .../site-packages/torchcodec/libtorchcodec_image.so
warnings.warn(
torch 2.9.0+cpu | torchaudio 2.9.0+cpu | pyannote.audio 4.0.7
import OK
The import works. The warning is from our test box, which has no FFmpeg installed: TorchCodec needs the FFmpeg libraries to decode audio files. Either install FFmpeg, or pass audio already in memory as {"waveform": tensor, "sample_rate": sr}, as the warning says. pyannote.audio 4 is a major version, so check its release notes before switching a working 3.x pipeline.
Related: torchaudio has no attribute info · Could not load libtorchcodec · torch.load: Weights only load failed · ultralytics YOLO: Weights only load failed · No module named torchaudio.backend · No module named torchaudio.io
Frequently asked questions
Which torchaudio version removed AudioMetaData?
In our test it exists on torchaudio 2.8.0 and is gone on 2.9.0.
Why does a fresh install break?
pyannote.audio 3.3.2 requires torchaudio>=2.2.0 with no upper bound, so pip installs the newest torchaudio.
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, pyannote.audio 3.3.2 and 4.0.7. Output pasted unedited except shortened site-packages paths and a cut traceback. PlainTables is our extension; pyannote.audio and PyTorch are free.