Problem with pyannote.audio==3.1.0

It seems like a partial hit.:sweat_smile: 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.

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)
  • write_rttm is defined on pyannote.core.Annotation, not on the wrapper. (pyannote.github.io)
  • 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)

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)

1 Like