# Problem with pyannote.audio==3.1.0

**URL:** <https://discuss.huggingface.co/t/problem-with-pyannote-audio-3-1-0/169326>\
**Category:** Beginners\
**Created:** [October 21, 2025, 1:54pm UTC](https://discuss.huggingface.co/t/problem-with-pyannote-audio-3-1-0/169326 "2025-10-21T13:54:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aldkela](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@aldkela](https://discuss.huggingface.co/u/aldkela)\
**Post date:** [October 21, 2025, 1:54pm UTC](https://discuss.huggingface.co/t/problem-with-pyannote-audio-3-1-0/169326/1 "2025-10-21T13:54:38Z")

</div>

Hello, I was trying to use model named pyannote/speaker-diarization-3.1

so I installed some libraries as below

```auto
%pip install pyannote.audio==3.1.0
%pip install numpy==1.26

```

Here is the result and I think I installed this properly…

```auto
Collecting pyannote.audio==3.1.0
  Using cached pyannote.audio-3.1.0-py2.py3-none-any.whl.metadata (7.8 kB)
Requirement already satisfied: asteroid-filterbanks>=0.4 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (0.4.0)
Requirement already satisfied: einops>=0.6.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (0.8.1)
Requirement already satisfied: huggingface-hub>=0.13.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (0.35.3)
Requirement already satisfied: lightning>=2.0.1 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (2.5.5)
Requirement already satisfied: omegaconf<3.0,>=2.1 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (2.3.0)
Requirement already satisfied: pyannote.core>=5.0.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (6.0.1)
Requirement already satisfied: pyannote.database>=5.0.1 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (6.1.0)
Requirement already satisfied: pyannote.metrics>=3.2 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (4.0.0)
Requirement already satisfied: pyannote.pipeline>=3.0.1 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (4.0.0)
Requirement already satisfied: pytorch-metric-learning>=2.1.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (2.9.0)
Requirement already satisfied: rich>=12.0.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (14.2.0)
Requirement already satisfied: semver>=3.0.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (3.0.4)
Requirement already satisfied: soundfile>=0.12.1 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (0.13.1)
Requirement already satisfied: speechbrain>=0.5.14 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (1.0.3)
Requirement already satisfied: tensorboardX>=2.6 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (2.6.4)
Requirement already satisfied: torch>=2.0.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (2.9.0+cu126)
Requirement already satisfied: torch-audiomentations>=0.11.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (0.12.0)
Requirement already satisfied: torchaudio>=2.0.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (2.9.0)
Requirement already satisfied: torchmetrics>=0.11.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from pyannote.audio==3.1.0) (1.8.2)
Requirement already satisfied: antlr4-python3-runtime==4.9.* in c:\gpt_agent_2025_book\venv\lib\site-packages (from omegaconf<3.0,>=2.1->pyannote.audio==3.1.0) (4.9.3)
Requirement already satisfied: PyYAML>=5.1.0 in c:\gpt_agent_2025_book\venv\lib\site-packages (from omegaconf<3.0,>=2.1->pyannote.audio==3.1.0) (6.0.3)
Requirement already satisfied: numpy in c:\gpt_agent_2025_book\venv\lib\site-packages (from asteroid-filterbanks>=0.4->pyannote.audio==3.1.0) (1.26.0)
Requirement already satisfied: typing-extensions in c:\gpt_agent_2025_book\venv\lib\site-packages (from asteroid-filterbanks>=0.4->pyannote.audio==3.1.0) (4.15.0)
...
    Uninstalling numpy-2.3.4:
      Successfully uninstalled numpy-2.3.4
Successfully installed numpy-1.26.0
Note: you may need to restart the kernel to use updated packages.
Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pyannote-core 6.0.1 requires numpy>=2.0, but you have numpy 1.26.0 which is incompatible.
pyannote-metrics 4.0.0 requires numpy>=2.2.2, but you have numpy 1.26.0 which is incompatible.

```

I ran this code to load the ffmpeg

```python
from pathlib import Path
import os, sys

ffmpeg_dll_dir = Path(r"C:\Users\majh0\miniconda3\Library\bin")  
assert ffmpeg_dll_dir.exists(), ffmpeg_dll_dir
os.add_dll_directory(str(ffmpeg_dll_dir))  

import torch, torchcodec, platform, subprocess
print("exe:", sys.executable)
print("torch", torch. __version__ , "torchcodec", torchcodec. __version__ , "py", platform.python_version())
subprocess.run(["ffmpeg", "-version"], check=True)
print("cuda torch?",torch.cuda.is_available())

```

and the result looks fine to me..

```auto
exe: c:\GPT_AGENT_2025_BOOK\venv\Scripts\python.exe
torch 2.9.0+cu126 torchcodec 0.8.0 py 3.12.9
cuda torch? True

```

I ran this code and it gave me an error as below…

```python
# instantiate the pipeline
import torch
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained(
  "pyannote/speaker-diarization-3.1",
  token="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")

if torch.cuda.is_available():
    pipeline.to(torch.device("cuda"))
    print("Using CUDA")
else:
    print("Using CPU")

```

```auto
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[3], line 3
      1 # instantiate the pipeline
      2 import torch
----> 3 from pyannote.audio import Pipeline
      4 pipeline = Pipeline.from_pretrained(
      5 "pyannote/speaker-diarization-3.1",
      6 token="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")
      9 if torch.cuda.is_available():

File c:\GPT_AGENT_2025_BOOK\venv\Lib\site-packages\pyannote\audio\ __init__.py:29
     25 except ImportError:
     26 pass
---> 29 from .core.inference import Inference
     30 from .core.io import Audio
     31 from .core.model import Model

File c:\GPT_AGENT_2025_BOOK\venv\Lib\site-packages\pyannote\audio\core\inference.py:36
     33 from pyannote.core import Segment, SlidingWindow, SlidingWindowFeature
     34 from pytorch_lightning.utilities.memory import is_oom_error
---> 36 from pyannote.audio.core.io import AudioFile
     37 from pyannote.audio.core.model import Model, Specifications
     38 from pyannote.audio.core.task import Resolution
...
     49 - a "str" or "Path" instance: "audio.wav" or Path("audio.wav")
   (...) 56 integer to load a specific channel: {"audio": "stereo.wav", "channel": 0}
     57 """

AttributeError: module 'torchaudio' has no attribute 'set_audio_backend'

```

I have checked the document and it says I need to install [`pyannote.audio`](https://github.com/pyannote/pyannote-audio) `3.1`

I don’t know why this thing doesn’t work…. I tried to solve this problem for 3hrs changing version of pyannote.audio but this thing didn’t give me solution..

Do I need to delete venv and reinstall it clearly..?

Thank you so much for the help in advance..

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [October 22, 2025, 2:49am UTC](https://discuss.huggingface.co/t/problem-with-pyannote-audio-3-1-0/169326/2 "2025-10-22T02:49:32Z")

</div>

Seems library version incompatibility…

* * *

Your import error comes from an API removal in torchaudio and an incompatible NumPy pin. Fix by upgrading `pyannote.audio` and undoing the NumPy downgrade. Keep your Torch 2.9 stack.

# TL;DR fix

```bash
# clean conflicting pins
pip uninstall -y pyannote.audio pyannote.core pyannote.metrics pyannote.pipeline pyannote.database numpy

# install a compatible, modern set
pip install --upgrade "numpy>=2.3" "pyannote.audio>=4.0.1" --prefer-binary
# keep your existing torch==2.9.*, torchaudio==2.9.* and torchcodec

```

`pyannote.audio>=4` removed the old torchaudio backend call and uses FFmpeg via `torchcodec`, so the import works on torchaudio≥2.2. NumPy≥2.x satisfies `pyannote-core` and `pyannote-metrics`. ([GitHub](https://github.com/pyannote/pyannote-audio/releases "Releases · pyannote/pyannote-audio"))

Then restart the kernel once. Verify:

```python
# refs:
# - torchaudio dispatcher notes: https://docs.pytorch.org/audio/main/torchaudio.html
# - pyannote model card: https://huggingface.co/pyannote/speaker-diarization-3.1
import torchaudio, torchcodec
print("backends:", torchaudio.list_audio_backends()) # should show 'ffmpeg' and/or 'soundfile'
from pyannote.audio import Pipeline
pipe = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1", token="hf_xxx") # do not hardcode secrets

```

`set_audio_backend` was deprecated, then removed in torchaudio 2.2+, which is why `pyannote.audio==3.1.0` fails to import on your current torchaudio. ([PyTorch Docs](https://docs.pytorch.org/audio/main/torchaudio.html "Torchaudio 2.8.0 documentation"))

# Why your install failed

- `pyannote.audio==3.1.0` calls `torchaudio.set_audio_backend("soundfile")`. That function is gone in torchaudio≥2.2, so import raises `AttributeError`. Upgrading pyannote fixes it because 4.x removed that path. ([GitHub](https://github.com/pyannote/pyannote-audio/issues/1576 "Removing torchaudio.set\_audio\_backend(”soundfile”) #1576"))
- You forced `numpy==1.26`. Current pyannote ecosystem components require NumPy≥2.0 (core) and ≥2.2.2 (metrics). Pip warned correctly. Use NumPy≥2.3. ([GitHub](https://github.com/huggingface/transformers/issues/41230 "Consider forking and maintaining pyctcdecode #41230"))

# If you must stay on `pyannote.audio==3.1.0` (not recommended)

Pick one, not both:

```bash
# Legacy stack that still has set_audio_backend
pip install "torch<=2.1.2" "torchaudio<=2.1.2" "numpy>=2.0,<3" "pyannote.audio==3.1.0"

```

or a temporary shim:

```python
# WARNING: local hack to import 3.1.0 with new torchaudio
import torchaudio
if not hasattr(torchaudio, "set_audio_backend"):
    torchaudio.set_audio_backend = lambda *a, **k: None
    torchaudio.get_audio_backend = lambda: "soundfile"
from pyannote.audio import Pipeline

```

The first aligns versions to when the API existed. The second bypasses the call so you can upgrade later. ([PyTorch Docs](https://docs.pytorch.org/audio/main/torchaudio.html "Torchaudio 2.8.0 documentation"))

# Gating and FFmpeg checks

- Accept the model terms for `pyannote/speaker-diarization-3.1` on Hugging Face and pass a valid token, or downloads will fail. ([Hugging Face](https://huggingface.co/pyannote/speaker-diarization-3.1 "pyannote/speaker-diarization-3.1"))
- `pyannote.audio>=4` expects FFmpeg via `torchcodec`. You already verified FFmpeg and `torchcodec`, which matches the 4.x I/O design. ([GitHub](https://github.com/pyannote/pyannote-audio/releases "Releases · pyannote/pyannote-audio"))

# Sanity test end-to-end

```python
# refs in comments:
# https://huggingface.co/pyannote/speaker-diarization-3.1
# https://docs.pytorch.org/audio/main/torchaudio.html
import torch
from pyannote.audio import Pipeline
pipe = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1", token="hf_xxx")
if torch.cuda.is_available():
    pipe.to("cuda")
result = pipe("sample.wav") # 16 kHz mono recommended
print(result)

```

The model card confirms “pyannote.audio version 3.1 or higher,” so using 4.x is valid and simpler on modern Torch. ([Hugging Face](https://huggingface.co/collinbarnwell/pyannote-speaker-diarization-31 "collinbarnwell/pyannote-speaker-diarization-31"))

# Extra context and references

- Torchaudio 2.2+ removed `set_audio_backend` and switched to a dispatcher. That is the precise cause of your `AttributeError`. ([PyTorch Docs](https://docs.pytorch.org/audio/main/torchaudio.html "Torchaudio 2.8.0 documentation"))
- pyannote 4.x release notes: removed `sox`/`soundfile` backends; use FFmpeg or in-memory audio. Explains why 4.x works on Windows with `torchcodec`. ([GitHub](https://github.com/pyannote/pyannote-audio/releases "Releases · pyannote/pyannote-audio"))
- NumPy≥2 requirement in the pyannote stack. Avoid forcing 1.26. ([GitHub](https://github.com/huggingface/transformers/issues/41230 "Consider forking and maintaining pyctcdecode #41230"))

Deleting the venv is optional. Uninstall→reinstall with the versions above and one kernel restart is sufficient.

---

<div class="post-metadata">

**Author:** ![aldkela](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@aldkela](https://discuss.huggingface.co/u/aldkela)\
**Post date:** [October 22, 2025, 12:34pm UTC](https://discuss.huggingface.co/t/problem-with-pyannote-audio-3-1-0/169326/3 "2025-10-22T12:34:52Z")

</div>

Hello! Thank you so much!! I realized.. I should read the error msg properly to solve the problem!!! xD

I have one more problem….

I made a code as below..

```python
from pathlib import Path
import os, sys

ffmpeg_dll_dir = Path(r"C:\Users\majh0\miniconda3\Library\bin")  
assert ffmpeg_dll_dir.exists(), ffmpeg_dll_dir
os.add_dll_directory(str(ffmpeg_dll_dir))  

import torch, torchcodec, platform, subprocess
print("exe:", sys.executable)
print("torch", torch. __version__ , "torchcodec", torchcodec. __version__ , "py", platform.python_version())
subprocess.run(["ffmpeg", "-version"], check=True)
print("cuda torch?",torch.cuda.is_available())

# instantiate the pipeline
import torch
from pyannote.audio import Pipeline

pipeline = Pipeline.from_pretrained(
  "pyannote/speaker-diarization-3.1",
  token="my token")

if torch.cuda.is_available():
    pipeline.to(torch.device("cuda"))
    print("Using CUDA")
else:
    print("Using CPU")

audio_file ="./guitar.wav"
diarization = pipeline(audio_file)

# dump the diarization output to disk using RTTM format
with open("./guitar.rttm", "w", encoding="utf-8") as rttm:
    diarization.write_rttm(rttm)

```

this thing gave me error as below…

```auto
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[15], line 6
      4 # dump the diarization output to disk using RTTM format
      5 with open("./guitar.rttm", "w", encoding="utf-8") as rttm:
----> 6 diarization.write_rttm(rttm)

AttributeError: 'DiarizeOutput' object has no attribute 'write_rttm'

```

This thing is hard to understand for me… because I literally typed “diarization.write\_rttm(rttm)” same with the example of this document like picture below [https://huggingface.co/pyannote/speaker-diarization-3.1](https://huggingface.co/pyannote/speaker-diarization-3.1)

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/e/1/e12f6fb814a9818839879f59f631cf0ed994b78d.png)

the name of the function “write\_rttm” has changed? then is there any way to check the new name of it..?

or did I make another mistake again..?

I think I am bothering you too much.. but thank you so much for your help..

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [October 22, 2025, 12:48pm UTC](https://discuss.huggingface.co/t/problem-with-pyannote-audio-3-1-0/169326/4 "2025-10-22T12:48:54Z")

</div>

It seems like a partial hit.😅 The cause is a specification change due to a library version upgrade, but it appears to be because the returned object changed, not because the function itself changed.

* * *

You’re on `pyannote.audio` 4.x. In 4.x the pipeline returns a **`DiarizeOutput`** object, not an `Annotation`. The `Annotation` lives at `output.speaker_diarization`. `write_rttm` is a method of `Annotation`, so call it there.

```python
from pyannote.audio import Pipeline
import torch

pipeline = Pipeline.from_pretrained(
    "pyannote/speaker-diarization-3.1",
    token="YOUR_HF_TOKEN"
)
if torch.cuda.is_available():
    pipeline.to("cuda")

out = pipeline("./guitar.wav") # out is DiarizeOutput
ann = out.speaker_diarization # this is an Annotation

with open("./guitar.rttm", "w", encoding="utf-8") as f:
    ann.write_rttm(f)

```

Evidence

- The current README shows usage as `output = pipeline(...); for turn, spk in output.speaker_diarization: ...`, proving the wrapper return type in 4.x. ([GitHub](https://github.com/pyannote/pyannote-audio "GitHub - pyannote/pyannote-audio: Neural building blocks for speaker diarization: speech activity detection, speaker change detection, overlapped speech detection, speaker embedding"))
- `write_rttm` is defined on `pyannote.core.Annotation`, not on the wrapper. ([pyannote.github.io](https://pyannote.github.io/pyannote-core/_modules/pyannote/core/annotation.html "Source code for pyannote.core.annotation"))
- The model card snippet you followed is the legacy 3.1 example that returned an `Annotation` directly. That is why your call failed on 4.x. ([Hugging Face](https://huggingface.co/pyannote/speaker-diarization-3.1 "pyannote/speaker-diarization-3.1"))

Option if you want the old behavior: pin to the legacy stack (`pyannote.audio==3.1.x`) where `pipeline(...)` returns an `Annotation`, and the snippet `diarization.write_rttm(...)` works as-is. Note 4.x introduced several breaking changes, including API renames. ([GitHub](https://github.com/pyannote/pyannote-audio/releases "Releases · pyannote/pyannote-audio"))

---

<div class="post-metadata">

**Author:** ![aldkela](https://avatars.discourse-cdn.com/v4/letter/a/4bbf92/32.png) [@aldkela](https://discuss.huggingface.co/u/aldkela)\
**Post date:** [October 23, 2025, 6:31pm UTC](https://discuss.huggingface.co/t/problem-with-pyannote-audio-3-1-0/169326/5 "2025-10-23T18:31:44Z")

</div>

Hello, finally it works!!!

I thought I made mistake again.. I didn’t even think there was a change due to a library version upgrade..

Thank you so much now I can use this model without any problem!!!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](https://discuss.huggingface.co/u/system)\
**Post date:** [October 24, 2025, 6:32am UTC](https://discuss.huggingface.co/t/problem-with-pyannote-audio-3-1-0/169326/6 "2025-10-24T06:32:17Z")

</div>

Closed on October 24, 2025, 6:32am UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
