Skip to content

Fix PyTorch 2.6+ compatibility for pyannote speaker detection#252

Open
MatthiasHeim wants to merge 1 commit intokaixxx:mainfrom
MatthiasHeim:fix/pytorch-2.6-pyannote-compatibility
Open

Fix PyTorch 2.6+ compatibility for pyannote speaker detection#252
MatthiasHeim wants to merge 1 commit intokaixxx:mainfrom
MatthiasHeim:fix/pytorch-2.6-pyannote-compatibility

Conversation

@MatthiasHeim
Copy link

Summary

  • Fix speaker detection breaking with PyTorch 2.6+ due to weights_only=True default change
  • Add required safe globals for pyannote model checkpoint loading
  • Add omegaconf to requirements files

Problem

PyTorch 2.6 changed the default value of weights_only in torch.load() from False to True. This breaks loading pyannote model checkpoints that contain pickled objects like Specifications, Problem, and Resolution classes.

Error message:

_pickle.UnpicklingError: Weights only load failed...
WeightsUnpickler error: Unsupported global: GLOBAL pyannote.audio.core.task.Specifications was not an allowed global by default.

Solution

Add the required classes to torch.serialization.safe_globals before loading the pyannote pipeline in pyannote_mp_worker.py:

from pyannote.audio.core.task import Specifications, Problem, Resolution
from omegaconf import ListConfig, DictConfig
torch.serialization.add_safe_globals([Specifications, Problem, Resolution, ListConfig, DictConfig])

Test plan

  • Tested speaker detection with pyannote.audio 4.0.2 and PyTorch 2.8.0 on macOS
  • Verified speaker labels (S00, S01, etc.) appear in transcripts
  • Confirmed all pyannote pipeline stages complete (segmentation, speaker_counting, embeddings, discrete_diarization)

Related issues

🤖 Generated with Claude Code

PyTorch 2.6 changed the default value of `weights_only` in `torch.load()`
from `False` to `True`, which breaks loading pyannote model checkpoints
that contain pickled objects like `Specifications`, `Problem`, and
`Resolution` classes.

This fix adds the required classes to `torch.serialization.safe_globals`
before loading the pyannote pipeline, allowing speaker detection to work
with PyTorch 2.6+ and pyannote.audio 4.x.

Changes:
- Add safe globals for pyannote and omegaconf classes in pyannote_mp_worker.py
- Add omegaconf to requirements files (needed for ListConfig/DictConfig)

Fixes issue related to: pyannote/pyannote-audio#1908

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kaixxx
Copy link
Owner

kaixxx commented Dec 4, 2025

On what system are you working? I have not seen this error on Windows or macOS (arm).
Are you on an Intel x86 Mac? We haven't been able to get noScribe with pyannote 4 working on this system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants