🤗 Diarizers (v1.3.0) — Unified Open-Source ASR, Forced Alignment, Speaker Diarization, and DiarizationLM Post-Processing
Table of Contents
- Overview
- Configurable Pipeline Profiles (
best-quality,max,balanced,fast,acoustic-only) - Architecture
- Why 2024
DiarizersLMHad 43.99%–56.79% WDER & HowdiarizersSolves It - Evaluation Results
- What's New in
v1.3.0:Qwen3-ForcedAligner-0.6B, ExactDER/JER& Overlap-Aware Hybrid RTTM - Table 0a: End-to-End
diarizersv1.3.0(WDER&cpWERon211Held-Out Test Recordings) - Table 0b: Continuous-Time Exact
DER&JERBenchmark (211Held-Out Test Recordings) - Table 1: Open-Source Frontend (
diarizersv1.0.1 Legacy Baseline) +DiarizationLM-Gemma-4-E4B-v1 - Decomposed Stage-by-Stage Ablation, Model Reuse & Multi-Party Meeting Analysis
- Table 2: USM + Turn-to-Diarize Frontend +
DiarizationLM-Gemma-4-E4B-v1
- What's New in
- Installation
- How to Run the Pipeline
- 1. One-Liner End-to-End Python API (
DiarizersPipeline.from_pretrained) - 2. Modular End-to-End Python API (
DiarizationPipeline) - 3. Post-Processing Any Diarized Transcript with
DiarizationLM - 4. Command-Line Interface (
diarizersCLI &scripts/) - 5. Training & Exporting Custom DiarizationLM Models
- 6. Evaluating
WER,WDER,cpWER,SpkCntMAE,DER, andJER - 7. Interactive CPU Demos (
hf_space/app.py&hf_space/index.html)
- 1. One-Liner End-to-End Python API (
- Data Format
- Repository Structure
- Pretrained Models on Hugging Face
- Running Tests & Linter
- Citation
Overview
diarizers (v1.3.0) is a unified, self-contained Apache-2.0 Python library and CLI for end-to-end speaker-attributed automatic speech recognition (ASR + Forced Alignment + Speaker Diarization + DiarizationLM Post-Processing), continuous-time DER / JER and word-level WDER / cpWER evaluation, and training custom DiarizationLM models.
It combines:
- Word-Timestamped Open-Source ASR (
diarizers.asr): Defaulting toopenai/whisper-large-v3-turbo(MIT License) with segment-level timestamp decoding and character-proportional word timestamp interpolation (and also supportingQwen/Qwen3-ASRGGUF viaaudio.cpp, Apache-2.0 License, or precomputed word segments). - Offline Word-Level Forced Alignment (
diarizers.forced_alignment, New inv1.3.0): Powered byQwen/Qwen3-ForcedAligner-0.6B(Apache-2.0, enabled by default inbest-quality,max, andbalanced), replacing coarse ASR character-interpolated timestamps with exact acoustic word boundaries via natural-pause chunking and 1-to-1 Levenshtein DP reconciliation (preserving 100% of ASR words). Supports both fast CPU GGUF inference viaaudio.cpp(audiocpp_cli) and GPU/CPU PyTorch inference viaqwen-asr, with automatic graceful fallback to ASR timestamps when optional aligner runtimes are not installed. - Overlapping Powerset Speaker Segmentation + Diarization-Trained FlaxSpeaker / ECAPA Embeddings + Auto-
KClustering (diarizers.diarization,diarizers.flaxspeaker_encoder&diarizers.spectral):- Standalone pure-PyTorch implementation of
pyannote/segmentation-3.0(PyanNetSegmentation: SincNet + 4-layer BiLSTM + 7-class powerset classifier, MIT License, with automatic fallback to un-gated mirrors) extracting clean overlapping single-speaker tracks (powerset_ward). - Standalone pure-PyTorch implementations of
wq2012/FlaxSpeakerdiarization-trainedSimAM-ERes2Conformerencoders (wq2012/univ_full_eres2conformer_xl_diar_adapt64.4M,xl_diar_pfas77.1M,v2_diar36.3M, andxl_diar64.4M, withcos = 1.0000000float32 parity against native JAX and automatic per-segment CMVNflaxspeaker_cmvn_mode="segment"),speechbrain/spkrec-ecapa-voxceleb(SpeechBrainECAPATDNN,20.8M,15×faster on CPU), and dual-encoder fusion (xl_diar_adapt + ECAPA,secondary_fusion_weight=0.35). - Ward Auto-
K+ Cannot-Link Cosine EM + Balanced Speaker-Centroid Centering + Soft Powerset Stitching (powerset_ward) + Two-Threshold Overlap-Aware RTTM Decoding (probs_to_rttm_turns,primary_threshold=0.40, overlap_threshold=0.55), alongside the clean-room Symmetric Normalized Laplacian Spectral Clusterer (diarization_mode="sliding_spectral").
- Standalone pure-PyTorch implementation of
- Sub-Millisecond Frame-Posterior Alignment, Hybrid RTTM Fusion & Chunked Prompting (
diarizers.alignment): Soft frame-probability word assignment (assign_speakers_from_probs_with_map— automatically switching to unsmoothed frame probabilitiesprob_smooth_sec=0.0whenever forced alignment is active), Acoustic-Margin-Gated Stage 2 + Stage 4 Hybrid Fusion (fuse_frame_probs_with_llm, cutting Strict DER by-7.52 ppvsv1.2.0to_rttm()), script-aware multilingual tokenization (tokenize_multilingual_text), and 4,000-character chunked prompt building (ChunkedPromptBuilder). - Multilingual DiarizationLM Post-Processing &
LG-TPST(diarizers.llm&diarizers.alignment): Post-processing viadiarizers-community/DiarizationLM-Gemma-4-12B-v1(highest accuracy, default inbest-quality,max, andbalanced) anddiarizers-community/DiarizationLM-Gemma-4-E4B-v2(2×faster & half the RAM infast), supporting automatic 4-bitQ4_K_MGGUF inference on CPU viallama.cppandbfloat16Safetensors on GPU via Hugging Facetransformers, paired with Myers' (1999) bit-parallel exact word-level Levenshtein alignment (tpst_align), Hungarian inter-chunk permutation reconciliation, and Locality-Gated Transcript-Preserving Speaker Transfer (LG-TPST). - Pure-NumPy/SciPy Exact Evaluation (
diarizers.evaluation): Exact continuous-time DER (Miss, FA, Confusion) and JER (evaluate_der_jer,evaluate_rttm_files,parse_rttm,parse_uem,bootstrap_paired_der_jer_ci, verified< 1e-7parity vspyannote.metrics/ NISTmd-eval) alongside Hungarian WER, WDER, cpWER, and SpkCntMAE.
Archival Note: All functionality from the experimental
diarizers-community/DiarizersLMrepository has been folded into and superseded bydiarizers(v1.0.0+).
diarizers (v1.3.0) implements and extends the algorithms described in:
- DiarizationLM: Quan Wang, Yiling Huang, Guanlong Zhao, Evan Clark, Wei Xia, Hank Liao, "DiarizationLM: Speaker Diarization Post-Processing with Large Language Models", Interspeech 2024 (arXiv:2401.03506).
- Turn-to-Diarize: Wei Xia, Han Lu, Quan Wang, Anshuman Tripathi, Yiling Huang, Ignacio Lopez Moreno, Hasim Sak, "Turn-to-Diarize: Online Speaker Diarization Constrained by Transformer Transducer Speaker Turn Detection", ICASSP 2022 (arXiv:2109.11641).
- SpectralCluster: Quan Wang, Carlton Downey, Li Wan, Philip Andrew Mansfield, Ignacio Lopez Moreno, "Speaker Diarization with LSTM", ICASSP 2018 (arXiv:1710.10468).
Configurable Pipeline Profiles (best-quality, max, balanced, fast, acoustic-only)
Because speaker encoders (ECAPA 20.8M vs. FlaxSpeaker-v2-Diar 36.3M vs. FlaxSpeaker-XL-Diar-Adapt 64.4M, 10–15× CPU speed difference), offline forced alignment (Qwen3-ForcedAligner-0.6B), and DiarizationLM sizes (Gemma-4-E4B-v2 vs. Gemma-4-12B-v1, 2× CPU speed and 2× RAM difference) span a wide compute-cost spectrum, diarizers exposes five readable high-level profiles via profile=... (Python) and --profile ... (CLI):
Profile (--profile / profile=) |
Aliases | Word Aligner (Stage 1.5) |
Stage 2 Acoustic Diarizer (powerset_ward) |
Stage 4 DiarizationLM | 211-Test Micro / Macro WDER (%) | Strict / NIST DER (%) | SpkCntMAE |
Best For |
|---|---|---|---|---|---|---|---|---|
"max" |
fusion, gpu |
Qwen3-ForcedAligner-0.6B (default ON) |
FlaxSpeaker-XL-Diar-Adapt + ECAPA Fusion (w=0.35) |
DiarizationLM-Gemma-4-12B-v1 |
3.47 / 4.69 (7.01% AMI, 2.39% Fisher) | 22.85 / 7.79 (7.27 non-ovl) | 0.174 | Maximum SOTA WDER, DER/JER & meetings |
"best-quality" (default) |
best, quality, default, flaxspeaker |
Qwen3-ForcedAligner-0.6B (default ON) |
FlaxSpeaker-XL-Diar-Adapt (64.4M, segment-CMVN) |
DiarizationLM-Gemma-4-12B-v1 |
3.52 / 4.71 (3.45% CALLHOME, 7.18% AMI) | 22.82 / 7.84 (7.29 non-ovl) | 0.177 | Default single-encoder champion & auto-K |
"balanced" |
ecapa-12b, cpu-12b |
Qwen3-ForcedAligner-0.6B (default ON) |
ECAPA-TDNN (20.8M, 15× faster CPU encoder) |
DiarizationLM-Gemma-4-12B-v1 |
3.54 / 4.77 (5.59% ICSI) | 23.12 / 7.97 (7.43 non-ovl) | 0.239 | CPU servers (>= 24 GiB RAM), fast encoder |
"fast" |
lite, cpu, e4b |
None (optional --word-aligner qwen3) |
ECAPA-TDNN (20.8M) |
DiarizationLM-Gemma-4-E4B-v2 |
4.13 / 5.49 (3.71 / 5.01 w/ Fusion+Qwen3) | 23.17 / 7.97 | 0.239 | 16 GiB laptops, CPU servers & Spaces (~7.6 GiB RAM) |
"acoustic-only" |
no-llm, realtime |
None (optional) |
ECAPA-TDNN (20.8M) |
None (disabled) |
5.65 / 6.96 | 23.19 / 8.03 | 0.239 | Ultra-low-resource / real-time CPU (<2 GiB RAM) |
(Note: When Qwen3-ForcedAligner-0.6B is enabled by a profile default and neither qwen-asr nor audiocpp_cli is installed, diarizers emits a RuntimeWarning and gracefully falls back to Whisper timestamps. Install via pip install "diarizers[align]" or pass word_aligner=None / --word-aligner none to opt out cleanly.)
Architecture
Audio (WAV / FLAC / MP3 / 16 kHz mono NumPy array)
├──> Stage 1: ASR Backend (diarizers.asr)
│ └── WhisperWordASR (openai/whisper-large-v3-turbo) or AudioCppASR (Qwen3-ASR)
│ ──> Coarse WordSegments [start, end, word]
│ │
│ ▼
│ Stage 1.5: Offline Forced Alignment (diarizers.forced_alignment, default in best-quality/max/balanced)
│ └── Qwen3ForcedAligner / AudioCppForcedAligner (Qwen/Qwen3-ForcedAligner-0.6B)
│ ├── Natural-pause ~30s chunking + Levenshtein DP 1-to-1 reconciliation (100% word preservation)
│ └── Exact acoustic WordSegments [start, end, word]
│
└──> Stage 2: Powerset Speaker Diarization Backend (diarizers.diarization, flaxspeaker_encoder & spectral)
├── PyanNetSegmentation (pyannote/segmentation-3.0 overlapping 10s powerset clean-speaker masks)
├── Speaker Encoder: FlaxSpeakerERes2Conformer (best-quality/max), SpeechBrainECAPATDNN (balanced/fast),
│ or Dual-Encoder Fusion (max)
└── powerset_ward: Ward Auto-K + Cannot-Link Cosine EM + Balanced Centering + Soft Powerset Stitching
──> Continuous Frame Posteriors P(t, k) (raw & smoothed) + Two-Threshold Overlap-Aware Turns
│
▼
Stage 3: Soft Posterior Alignment & Chunked Prompt Builder (diarizers.alignment)
├── assign_speakers_from_probs_with_map (raw P when forced-aligned, smoothed P otherwise)
└── ChunkedPromptBuilder (4,000-char or UTF-8 byte windows, Gemma-4 turn formatting)
│
▼
Stage 4: DiarizationLM Post-Processing & LG-TPST (diarizers.llm & diarizers.alignment)
├── DiarizationLMRefiner (12B-v1 in 'best-quality'/'max'/'balanced' | E4B-v2 in 'fast')
│ ├── CPU Auto Backend: llama-cpp-python (Q4_K_M GGUF + flash_attn)
│ └── GPU Backend: Hugging Face transformers (bfloat16 model.safetensors)
├── Hungarian Inter-Chunk Speaker Permutation Reconciliation
├── Myers' (1999) Bit-Parallel Exact Word-Level Levenshtein TPST (tpst_align)
└── Locality-Gated Speaker Transfer (LG-TPST)
│
▼
Stage 5 (Export): Acoustic-Margin-Gated Hybrid RTTM Fusion & Multi-Format Exports
├── fuse_frame_probs_with_llm (injects Stage 4 swaps where acoustic margin <= 0.50; preserves overlap)
├── probs_to_rttm_turns (two-threshold overlap-aware or non-overlapping NIST RTTM)
└── DiarizedTranscript (Diarized Text, Overlap-Aware Hybrid RTTM, SRT, WebVTT, JSON)
Why 2024 DiarizersLM Had 43.99%–56.79% WDER & How diarizers Solves It
In the 2024 experimental DiarizersLM prototype (distil-whisper/distil-large-v3 + pyannote/speaker-diarization-3.1 + Llama-2-7b), Word Diarization Error Rate (WDER) degraded to 43.99% on Fisher and 56.79% on AMI (nearly random guessing on 2-speaker telephone calls). A systematic audit identified six compounding root causes, all resolved in diarizers (v1.0.1):
- Open-End Timestamp Crash (
[start, None]): Whisper frequently emitsNonefor the end timestamp of the final segment in a 30-second chunk;DiarizersLMcrashed or dropped trailing words.diarizers.alignment.assign_speakerssafely bounds open-ended timestamps (start + 0.1s). - Silence Fallback Speaker Collapse: In
DiarizersLM, any word whose timestamp fell in a brief inter-turn pause with zero overlap defaulted toturns[0].speaker(always Speaker 1).diarizersassigns non-overlapping words to the temporally nearest speaker turn by midpoint distance. - Integer-Second Timestamp Truncation:
DiarizersLMcast word and turn timestamps to integer seconds (round(t)), erasing sub-second conversational turn boundaries and backchannels ("yeah","uh-huh").diarizerspreserves fullfloat64sub-millisecond precision throughout alignment and supports arbitrary integer speaker counts (>= 10speakers). - 8 kHz Telephony Acoustic Collapse, Exact HTK Mel Filterbanks & Neural Powerset Segmentation:
- Pretrained
speechbrain/spkrec-ecapa-voxcelebexpects HTK Mel filterbanks (_build_mel_filterbank_np) with decibel-scaled (10 * log10) 80-bin energies (blocks.0BatchNormrunning_mean ~ 71.85, running_var ~ 8536.5) and global embedding mean subtraction (mean_var_norm_emb.ckpt). Using natural-log (ln) filterbanks withoutglob_meansubtraction caused all embeddings to collapse into a narrow cone (cosine similarity > 0.90). - Furthermore, 8 kHz narrowband telephone audio upsampled to 16 kHz introduces a shared channel offset vector across all windows of a call.
diarizers.diarization.ECAPASpectralDiarizercombines standalone PyTorchpyannote/segmentation-3.0(PyanNetSegmentationneural powerset segmentation, MIT License) withSpeechBrainECAPATDNN(exact HTK dB filterbank scaling,glob_meansubtraction, and recording-level embedding centeringembs -= embs.mean(axis=0)) and clusters via Symmetric Normalized Laplacian Spectral Clustering (L_sym = I - D^{-1/2} W D^{-1/2}) with Gaussian temporal smoothing and calibrated eigengap speaker count estimation (eigen_threshold=0.45). Pure sliding-windowECAPA-TDNN + SpectralClusterer(without neural segmentation) also remains available viasegmentation_model="none".
- Pretrained
- Inter-Chunk Speaker Permutation Flips: Long transcripts segmented into 4,000-character LLM prompts previously suffered independent speaker label permutations (
1 <-> 2) across chunks.diarizers.alignment.ChunkedPromptBuilderdefaults tooverlap_words=0(matching the non-overlapping chunking used duringDiarizationLM-Gemma-4-E4B-v1SFT training) and supports configurable overlapping word windows (e.g.,overlap_words=60) with Hungarian (scipy.optimize.linear_sum_assignment) inter-chunk reconciliation. - LLM Monologue Speaker Drift & Ghost Speaker Hallucinations: Autoregressive LLMs occasionally invent a spurious
<speaker:3>in a 2-speaker conversation or flip a speaker label across a 200-word monologue, or fail to emit[eod]before repeating text.diarizerstruncates completions at the first occurrence of[eod]/<turn|>(truncate_completion_suffix) and appliesdiarizers.alignment.locality_gated_speaker_transfer(LG-TPST), which absorbs ghost clusters (<= 15words in>= 3-speaker meetings) into dominant speakers, gates long-span monologue flips (> 5words in>= 3-speaker meetings and> 15words in2-speaker conversations), and uses Myers' (1999) bit-parallel exact word-level Levenshtein Transcript-Preserving Speaker Transfer (TPST) soWERis mathematically invariant before and after LLM post-processing.
Evaluation Results
All metrics below are micro-averaged across the full evaluation splits (172 Fisher conversations, 20 CALLHOME-English calls, 3 ICSI meetings, and 16 AMI Mix-Headset meetings = 211 test recordings) using exact Hungarian-matching dynamic programming (diarizers.evaluation.compute_corpus_metrics / diarizationlm.compute_metrics_on_json_dict).
(Note: In accordance with dataset licensing policies, raw LDC/benchmark audio and intermediate decoded transcripts are not redistributed in this repository.)
What's New in v1.3.0: Qwen3-ForcedAligner-0.6B, Exact DER/JER & Overlap-Aware Hybrid RTTM
diarizers v1.3.0 solves two core limitations of ASR-driven diarization pipelines — coarse ASR-interpolated word timestamps and word-only RTTM exports missing overlapping speech and acoustic VAD boundaries — pushing end-to-end Micro WDER from 3.79% → 3.47% (4.69% Macro WDER) and cutting Strict Macro DER by -7.52 pp (30.35% → 22.85%) and NIST Macro DER by -3.83 pp (11.57% → 7.79%, or 7.27% in non-overlapping mode):
- Offline Word-Level Forced Alignment (
Qwen/Qwen3-ForcedAligner-0.6B, enabled by default inbest-quality,max, andbalanced): Replaces Whisper character-proportional word interpolation with exact acoustic word boundaries (Qwen3ForcedAligner/AudioCppForcedAligner) via natural-pause~30schunking and 1-to-1 Levenshtein DP reconciliation (99.98%matched words across395,782test words,100%ASR word preservation). When forced alignment runs, Stage 3 automatically uses unsmoothed frame posteriors (prob_smooth_sec=0.0), reducing AMI WDER by-0.91 pp(7.92% → 7.01%), ICSI WDER by-0.73 pp(6.53% → 5.80%), and 211-recording Micro WDER by-0.32 pp(p = 0.0000) across all four tested encoder × LLM combinations (10,000-resample paired cluster bootstrap). Even4BE4B-v2+Qwen3-ForcedAligner(3.71%Micro /5.01%Macro WDER) now outperformsv1.2.0's12B-v1+ Whisper-interpolated timestamps (3.79% / 5.14%). - Exact Continuous-Time
DER&JEREvaluator (diarizers.evaluation): Pure-NumPy/SciPy continuous-time interval algebra + optimal Hungarian speaker mapping (parse_rttm,parse_uem,evaluate_der_jer,aggregate_der_jer,evaluate_rttm_files,bootstrap_paired_der_jer_ci) verified to< 1e-7absolute error againstpyannote.metricsand NISTmd-eval, supporting both Strict (collar=0.0, skip_overlap=False) and NIST (collar=0.25, skip_overlap=True) protocols directly from Python anddiarizers evaluate --ref-rttm ... --hyp-rttm .... - Two-Threshold Overlap-Aware Decoding & Acoustic-Margin-Gated Stage 2 + Stage 4 Hybrid RTTM (
to_rttm(mode="auto"|"hybrid"|"acoustic"|"words", allow_overlap=True)): Preserves Stage 2's continuous~17 mspowerset VAD and simultaneous overlap detection (primary_threshold=0.40, overlap_threshold=0.55, cutting Strict DER-3.93 ppoverv1.2.0Stage 2 argmax) while injecting Stage 4DiarizationLMspeaker corrections on ambiguous acoustic frames (p_old - p_new <= 0.50). Across all four tested encoder × LLM systems,Qwen3-ForcedAligner+ Hybrid Fusion is the only strategy that statistically significantly beats calibrated acoustic Stage 2 on Strict DER (p <= 0.0112), Strict JER (p <= 0.0118), and NIST DER (p <= 0.0054) — whereas without forced alignment, Stage 4 hybrid fusion does not reach statistical significance on Strict DER (p = 0.259–0.951).
(Prior v1.2.0 upgrades remain included: diarization-adapted FlaxSpeaker SimAM-ERes2Conformer encoders with automatic per-segment CMVN, XL-Diar-Adapt + ECAPA dual-encoder fusion, SpkCntMAE = 0.174, and 5-tier profiles.)
Table 0a: End-to-End diarizers v1.3.0 (WDER & cpWER on 211 Held-Out Test Recordings, bfloat16)
All speaker counts are estimated automatically without oracle K (FISHER K=2 telephony preset unless marked K ∈ [1..10], CALLHOME [2..6], ICSI [2..10], AMI [3..5]). All alignment, smoothing, fusion, and threshold hyperparameters were calibrated strictly on a disjoint 60-recording dev set (19.0h) and frozen prior to blind held-out evaluation on all 211 test recordings (42.16h, 395,782 words).
Frontend + Aligner + DiarizationLM (Mode) |
Fisher (172) WDER / cpWER (%) | CALLHOME (20) WDER / cpWER (%) | ICSI (3) WDER / cpWER (%) | AMI (16) WDER / cpWER (%) | Micro WDER / Macro WDER (%) | SpkCntMAE (Macro) |
|---|---|---|---|---|---|---|
v1.0.1 (sliding_spectral + ECAPA) Base |
4.35 / 24.78 | 9.42 / 32.42 | 23.48 / 59.55 | 20.68 / 51.44 | 8.64 / 14.48 | 1.018 |
v1.0.1 + E4B-v1 (Raw-TPST) |
2.64 / 21.96 | 4.84 / 25.87 | 23.11 / 59.44 | 20.09 / 50.91 | 7.10 / 12.67 | 1.018 |
ECAPA (powerset_ward, acoustic-only) Base (Whisper ts) |
4.49 / 24.58 | 6.07 / 26.81 | 7.82 / 40.14 | 9.48 / 35.68 | 5.65 / 6.96 | 0.239 |
ECAPA + Whisper ts + E4B-v2 (LG-TPST, profile="fast") |
2.86 / 22.16 | 4.05 / 24.85 | 6.59 / 39.25 | 8.45 / 34.84 | 4.13 / 5.49 | 0.239 |
ECAPA + Whisper ts + 12B-v1 (LG-TPST, v1.2.0 balanced) |
2.61 / 21.85 | 3.75 / 24.30 | 6.50 / 39.19 | 8.11 / 34.44 | 3.88 / 5.25 | 0.239 |
FlaxSpeaker-V2-Diar (36.3M) + Whisper ts + 12B-v1 (LG-TPST) |
2.56 / 21.79 | 3.51 / 24.27 | 6.58 / 39.25 | 8.19 / 34.51 | 3.85 / 5.21 | 0.190 |
FlaxSpeaker-XL-Diar-Adapt + Whisper ts + 12B-v1 (v1.2.0 best-quality) |
2.56 / 21.78 | 3.53 / 24.21 | 6.50 / 39.17 | 8.04 / 34.37 | 3.82 / 5.16 | 0.177 |
XL-Diar-Adapt + ECAPA Fusion + Whisper ts + 12B-v1 (v1.2.0 max) |
2.55 / 21.78 | 3.57 / 24.12 | 6.53 / 39.21 | 7.92 / 34.24 | 3.79 / 5.14 | 0.174 |
XL-Diar-Adapt + ECAPA Fusion + Qwen3-Align Base (v1.3.0 S3) |
3.77 / 23.62 | 5.24 / 26.07 | 6.45 / 38.80 | 7.69 / 34.18 | 4.66 / 5.79 | 0.174 |
XL-Diar-Adapt + ECAPA Fusion + Qwen3-Align + E4B-v2 (LG-TPST) |
2.60 / 21.83 | 4.11 / 24.80 | 6.04 / 38.34 | 7.29 / 33.77 | 3.71 / 5.01 | 0.174 |
ECAPA + Qwen3-Align + 12B-v1 (v1.3.0 profile="balanced") |
2.44 / 21.63 | 3.81 / 24.36 | 5.59 / 37.99 | 7.23 / 33.65 | 3.54 / 4.77 | 0.239 |
FlaxSpeaker-XL-Diar-Adapt + Qwen3-Align + 12B-v1 (v1.3.0 profile="best-quality") |
2.43 / 21.61 | 3.45 / 24.18 | 5.76 / 38.16 | 7.18 / 33.64 | 3.52 / 4.71 | 0.177 |
XL-Diar-Adapt + ECAPA Fusion + Qwen3-Align + 12B-v1 (v1.3.0 profile="max") |
2.39 / 21.58 | 3.56 / 24.35 | 5.80 / 38.12 | 7.01 / 33.47 | 3.47 / 4.69 | 0.174 |
Unconstrained K ∈ [1..10]: XL-Diar-Adapt + Whisper ts + 12B-v1 |
3.05 / 22.15 | 3.53 / 24.21 | 6.50 / 39.17 | 8.04 / 34.37 | 4.17 / 5.28 | 0.216 |
All cpWER values above use the full all-speaker reference denominator (FISHER=323,413, CALLHOME=18,957, ICSI=33,255, AMI=88,826 words, counting unmapped reference speakers as full deletions) with standard Whisper text normalization. On exact paired unnormalized diarizers.evaluation.evaluate_utterance comparisons (10,000-resample paired cluster bootstrap), adding Qwen3-ForcedAligner-0.6B yields p = 0.0000 on Micro WDER and p <= 0.0010 on Macro WDER across all four systems (max: -0.32 pp [-0.43, -0.21] Micro WDER, -0.44 pp [-0.72, -0.12] Macro WDER; best-quality: -0.29 pp Micro / -0.46 pp Macro; balanced: -0.34 pp Micro / -0.48 pp Macro; Fusion + E4B-v2: -0.36 pp Micro / -0.46 pp Macro).
Table 0b: Continuous-Time Exact DER & JER Benchmark (211 Held-Out Test Recordings)
Evaluated with diarizers.evaluation.evaluate_der_jer over full-recording [0, duration] UEMs (Macro-averaged across Fisher 172, CALLHOME 20, ICSI 3, AMI 16). Strict uses collar=0.0, skip_overlap=False; NIST uses collar=0.25s per side (±0.25s) and skip_overlap=True:
RTTM Strategy (to_rttm(...) / Stage 2) |
Strict Macro DER (%) (Miss / FA / Conf) | Strict Macro JER (%) | NIST Macro DER (%) | NIST Macro JER (%) | Fisher (Str / NIST) | CALLHOME (Str / NIST) | ICSI (Str / NIST) | AMI (Str / NIST) |
|---|---|---|---|---|---|---|---|---|
v1.2.0 default to_rttm() (Whisper words, max) |
30.35 (16.8 / 9.6 / 4.0) | 33.18 | 11.57 | 15.12 | 23.2 / 4.7 | 27.1 / 8.6 | 33.7 / 9.0 | 37.4 / 23.9 |
v1.3.0 to_rttm(mode="words", max_gap_sec=2.0, pad_sec=0.1) (Qwen3, max) |
28.89 (19.9 / 5.8 / 3.2) | 32.70 | 9.88 | 14.46 | 22.3 / 4.8 | 27.2 / 9.4 | 36.2 / 12.7 | 29.9 / 12.6 |
v1.2.0 Stage 2 argmax (sm=0.25, p=0.05, max) |
26.84 (14.1 / 9.1 / 3.7) | 29.74 | 8.23 | 12.15 | 18.4 / 2.6 | 26.9 / 8.9 | 32.4 / 8.1 | 29.7 / 13.3 |
v1.3.0 to_rttm(mode="acoustic", allow_overlap=True) (max, Stage 2 only) |
22.91 (16.0 / 3.8 / 3.1) | 26.95 | 7.87 | 11.26 | 24.2 / 9.4 | 18.5 / 7.7 | 29.7 / 8.1 | 19.3 / 6.3 |
v1.3.0 to_rttm(mode="hybrid", allow_overlap=True) (profile="balanced") |
23.12 | 27.37 | 7.97 | 11.72 | — | — | — | — |
v1.3.0 to_rttm(mode="hybrid", allow_overlap=True) (profile="best-quality", Default) |
22.82 | 27.13 | 7.84 | 11.50 | — | — | — | — |
v1.3.0 to_rttm(mode="hybrid", allow_overlap=True) (profile="max") |
22.85 (16.0 / 3.8 / 3.0) | 26.84 | 7.79 | 11.06 | 24.0 / 9.2 | 18.4 / 7.6 | 29.6 / 8.1 | 19.3 / 6.3 |
v1.3.0 to_rttm(mode="hybrid", allow_overlap=False) (profile="max", Non-Overlap) |
25.30 (19.8 / 2.8 / 2.6) | 29.04 | 7.27 | 10.62 | 26.4 / 8.9 | 20.1 / 7.1 | 31.5 / 7.0 | 23.1 / 6.0 |
Paired 10,000-resample cluster bootstrap on profile="max": v1.3.0 default Hybrid RTTM beats v1.2.0 to_rttm() by -7.52 pp [-8.62, -6.52] Strict DER (p = 0.0000), -6.34 pp Strict JER (p = 0.0000), and -3.83 pp NIST DER (p = 0.0000); beats Qwen3 word-only RTTM by -6.04 pp Strict DER (p = 0.0000); and beats calibrated acoustic Stage 2 (mode="acoustic") by -0.06 pp Strict DER (p = 0.0014), -0.11 pp Strict JER (p = 0.0010), and -0.07 pp NIST DER (p = 0.0002) (replicated across all 4 encoder × LLM configurations).
DiarizationLM CPU Q4_K_M Memory & Speed Comparison (llama.cpp, n_ctx=6144):
Model (Apache-2.0) |
211-Test Micro / Macro WDER (ECAPA, LG-TPST) |
Q4_K_M File Size |
Peak CPU RSS (n_ctx=6144) |
CPU Speed (32 threads) |
Recommended Role |
|---|---|---|---|---|---|
Acoustic Baseline (ECAPA powerset_ward) |
5.65 / 6.96 | — | — | — | profile="acoustic-only" |
DiarizationLM-Gemma-4-E4B-v1 |
4.16 / 5.77 | 5.30 GB | 7.59 GiB |
15.1 tok/s |
Legacy (superseded by E4B-v2) |
DiarizationLM-Gemma-4-E4B-v2 |
4.13 / 5.49 (3.71 / 5.01 w/ Fusion+Qwen3) | 5.30 GB | 7.58 GiB |
15.4 tok/s |
profile="fast" (16 GiB RAM / CPU / Spaces) |
DiarizationLM-Gemma-4-12B-v1 |
3.54 / 4.77 (3.52 / 4.71 best-quality, 3.47 / 4.69 max) |
7.38 GB | 14.30 GiB |
7.5–8.0 tok/s |
profile="best-quality" (Default), "max" & "balanced" |
Table 1: Open-Source Frontend (diarizers v1.0.1 Legacy Baseline) + DiarizationLM-Gemma-4-E4B-v1
Open-source pipeline configuration:
- ASR:
openai/whisper-large-v3-turbo(WhisperWordASR, MIT License) - Speaker Diarization:
pyannote/segmentation-3.0(PyanNetSegmentation, MIT License) +speechbrain/spkrec-ecapa-voxceleb(SpeechBrainECAPATDNN, Apache-2.0 License) +SpectralClusterer(eigen_threshold=0.45, Apache-2.0 License) - DiarizationLM:
diarizers-community/DiarizationLM-Gemma-4-E4B-v1(Apache-2.0 License; evaluated in full-precisionbfloat16on TPU withmax_new_tokens = 1.2xinput tokens and6,000-character chunk windows; local CPU inference uses 4-bitQ4_K_MGGUF viallama.cppwithmax_tokens = 1.3xprompt tokens and4,000-character default chunk windows)
| Benchmark (Full Test Split) | Utterances | Pipeline / System | WER (%) | WDER (%) | cpWER (%) | SpkCntMAE |
|---|---|---|---|---|---|---|
| Fisher English | 172 | Legacy 2024 DiarizersLM (distil-large-v3 + pyannote-3.1) |
20.69 | 43.99 | 56.10 | — |
| Fisher English | 172 | diarizers v1.0.1 Open Frontend (FISHER_TELEPHONY_PRESET, Fixed Speaker Count K=2) |
20.80 | 4.35 (raw 4.45) | 24.78 (raw 24.78, Oracle 20.46) | 0.000 (fixed K=2) |
| Fisher English | 172 | diarizers v1.0.1 + DiarizationLM-Gemma-4-E4B-v1 (LG-TPST) |
20.80 | 2.59 | 21.91 | 0.000 (fixed K=2) |
| Fisher English | 172 | diarizers v1.0.1 + DiarizationLM-Gemma-4-E4B-v1 (Raw-TPST) |
20.80 | 2.65 | 21.99 | 0.000 (fixed K=2) |
| CALLHOME English | 20 | diarizers v1.0.1 Open Frontend (CALLHOME_TELEPHONY_PRESET, Auto Speaker Count [2..6], eigen_threshold=0.45) |
21.25 | 9.42 (raw 9.47) | 32.42 (raw 32.67, Oracle 21.08) | 0.050 |
| CALLHOME English | 20 | diarizers v1.0.1 + DiarizationLM-Gemma-4-E4B-v1 (LG-TPST) |
21.25 | 5.98 | 27.69 | 0.050 |
| CALLHOME English | 20 | diarizers v1.0.1 + DiarizationLM-Gemma-4-E4B-v1 (Raw-TPST) |
21.25 | 4.89 | 25.91 | 0.050 |
| ICSI Meeting Corpus | 3 | diarizers v1.0.1 Open Frontend (MEETING_MULTISPK_PRESET, Auto Speaker Count [2..10], eigen_threshold=0.45) |
35.29 | 23.48 (raw 23.58) | 48.97 (raw 59.55, Oracle 34.97) | 3.333 |
| ICSI Meeting Corpus | 3 | diarizers v1.0.1 + DiarizationLM-Gemma-4-E4B-v1 (LG-TPST) |
35.29 | 23.10 | 48.62 | 3.333 |
| ICSI Meeting Corpus | 3 | diarizers v1.0.1 + DiarizationLM-Gemma-4-E4B-v1 (Raw-TPST) |
35.29 | 23.11 | 48.63 | 3.333 |
AMI (Mix-Headset) |
16 | Legacy 2024 DiarizersLM (distil-large-v3 + pyannote-3.1) |
— | 56.79 | — | — |
AMI (Mix-Headset) |
16 | diarizers v1.0.1 Open Frontend (AMI_MEETING_PRESET, Auto Speaker Count [3..5], eigen_threshold=0.45) |
29.14 | 20.68 (raw 20.80) | 46.07 (raw 51.39, Oracle 28.70) | 0.688 |
AMI (Mix-Headset) |
16 | diarizers v1.0.1 + DiarizationLM-Gemma-4-E4B-v1 (LG-TPST) |
29.14 | 20.14 | 45.56 | 0.688 |
AMI (Mix-Headset) |
16 | diarizers v1.0.1 + DiarizationLM-Gemma-4-E4B-v1 (Raw-TPST) |
29.14 | 20.13 | 45.53 | 0.688 |
Note on Pre-Filter
*(raw ...)*vs. Ghost-Filtered Open-Frontend Baseline: In Table 1, the primary Open-FrontendWDERandcpWERcolumns report the Stage 3 acoustic diarization baseline after deterministic ghost-cluster absorption (apply_locality_gated_speaker_transfer(hyp_spk, hyp_spk, max_ghost_cluster_words=15)), while parenthetical*(raw ...)*values report the un-filtered Stage 3assign_speakersoutput prior to ghost-cluster absorption. On multi-speaker meetings (ICSI,AMI), absorbing tiny spurious acoustic clusters (<= 15words) reducescpWERby-10.58percentage points on ICSI (59.55% -> 48.97%) and-5.32percentage points on AMI (51.39% -> 46.07%) before any LLM inference, isolating the genuine lexical turn-boundary gains ofDiarizationLM-Gemma-4-E4B-v1(23.48% -> 23.10%WDER on ICSI;20.68% -> 20.13%WDER on AMI).
Decomposed Stage-by-Stage Ablation, Model Reuse & Multi-Party Meeting Analysis
1. Stage-by-Stage Decomposition & Continual Mixed-Frontend SFT Ablation (DiarizationLM-diarizers-Gemma-4-E4B-v1)
To separate the contribution of (a) the repaired Stage 1–3 acoustic frontend (assign_speakers), (b) deterministic Stage 3 ghost-cluster absorption (<= 15 words), (c) Stage 4 DiarizationLM-Gemma-4-E4B-v1 (Raw-TPST vs. LG-TPST), and (d) continual LoRA SFT on the open-source frontend (DiarizationLM-diarizers-Gemma-4-E4B-v1, trained on a 50/50 mixture of open-frontend and USM/Turn-to-Diarize locality-preserving SFT pairs), the table below reports all stages side-by-side across the full 211-utterance benchmark suite:
| Stage / System | Fisher (172) WDER / cpWER (%) | CALLHOME (20) WDER / cpWER (%) | ICSI (3) WDER / cpWER (%) | AMI (16) WDER / cpWER (%) |
|---|---|---|---|---|
0. Legacy 2024 DiarizersLM Prototype |
43.99 / 56.10 | — / — | — / — | 56.79 / — |
1. Stage 3 Raw Acoustic Alignment (assign_speakers) |
4.45 / 24.78 | 9.47 / 32.67 | 23.58 / 59.55 | 20.80 / 51.39 |
2. Stage 3 + Ghost-Cluster Absorption (<= 15 words) |
4.35 / 24.78 | 9.42 / 32.42 | 23.48 / 48.97 | 20.68 / 46.07 |
3. Stage 4 DiarizationLM-Gemma-4-E4B-v1 (Raw-TPST) |
2.65 / 21.99 | 4.89 / 25.91 | 23.11 / 48.63 | 20.13 / 45.53 |
4. Stage 4 DiarizationLM-Gemma-4-E4B-v1 (LG-TPST) |
2.59 / 21.91 | 5.98 / 27.69 | 23.10 / 48.62 | 20.14 / 45.56 |
5. Continual Mixed-Frontend SFT (DiarizationLM-diarizers-Gemma-4-E4B-v1, LG-TPST) |
2.61 / 21.93 (Raw: 2.64 / 21.93) | 5.98 / 27.75 (Raw: 4.89 / 25.96) | 23.12 / 48.66 (Raw: 23.12 / 48.65) | 20.32 / 45.66 (Raw: 20.30 / 45.64) |
Hungarian TPST Oracle Ceiling (hyp_spk_oracle) |
0.01 / 20.46 | 0.00 / 21.08 | 0.00 / 34.97 | 0.00 / 28.70 |
2. Justification for Reusing diarizers-community/DiarizationLM-Gemma-4-E4B-v1 (No Duplicate Model Release)
Comparing Row 4 (diarizers-community/DiarizationLM-Gemma-4-E4B-v1) against Row 5 (DiarizationLM-diarizers-Gemma-4-E4B-v1, continual mixed-frontend SFT) shows that both checkpoints achieve virtually identical performance across all 4 benchmarks (2.59% vs. 2.61% WDER on Fisher, 4.89% vs. 4.89% Raw-TPST and 5.98% vs. 5.98% LG-TPST on CALLHOME, 23.10% vs. 23.12% on ICSI, and 20.13% vs. 20.30% on AMI). Because DiarizationLM-Gemma-4-E4B-v1 was already trained with Locality-Preserving Oracle Supervision across all four corpora (51,063 Fisher + 20,762 Callhome/ICSI/AMI prompt-completion pairs) and operates purely on normalized text + <speaker:k> tokens, it transfers zero-shot to the diarizers open-source frontend without requiring a separate 16 GB checkpoint release.
3. Why Multi-Party Meeting (ICSI, AMI) LLM Gains Are Smaller Than Telephony (Fisher, CALLHOME)
While DiarizationLM-Gemma-4-E4B-v1 reduces WDER by -1.76 percentage points (-40.5% relative) on Fisher and -4.53 percentage points (-48.1% relative) on CALLHOME, post-LLM WDER reductions on tabletop multi-party meetings are more modest (-0.38 percentage points on ICSI, -0.55 percentage points on AMI; and -0.60 / -0.79 percentage points on the USM + Turn-to-Diarize frontend in Table 2). Three structural factors explain this regime difference:
- Higher Far-Field ASR Word Error Rate & Overlapped Speech: Tabletop meeting recordings exhibit higher ASR WER (
29.14%on AMI,35.29%on ICSI vs.20.80%–21.25%on telephony) and frequent simultaneous overlapped speech, which degrades lexical turn-boundary cues. - Global Speaker Count Estimation Error (
SpkCntMAE): Unbounded spectral clustering on 4–9 speaker meetings exhibitsSpkCntMAEof3.333on ICSI and0.688on AMI (compared to0.000on Fisher and0.050on CALLHOME). Because DiarizationLM is a local lexical boundary refiner rather than a global acoustic re-clusterer, global cluster merges/splits bound text-only post-processing. - Multi-Party Turn-Target Ambiguity ($K > 2$): In a 2-speaker call, identifying a lexical turn boundary uniquely determines the target speaker (
1 -> 2). In a 4–9 speaker meeting, even when syntax clearly indicates a speaker change, determining which of the other $K - 1$ participants spoke next is often lexically ambiguous without acoustic re-scoring.
Table 2: USM + Turn-to-Diarize Frontend + DiarizationLM-Gemma-4-E4B-v1
For reference, below is the performance of diarizers-community/DiarizationLM-Gemma-4-E4B-v1 on the exact same 211 test recordings when paired with the USM ASR and Turn-to-Diarize frontend (with 95% bootstrap confidence intervals over B = 10,000 conversation resamples; note that 0/10,000 bootstrap resamples had ΔWDER >= 0, and ICSI has n = 3 meetings):
| Benchmark | Test Split | WER (%) | System | WDER (%) [95% CI] | cpWER (%) [95% CI] | SpkCntMAE [95% CI] | Paired ΔWDER vs. Baseline |
|---|---|---|---|---|---|---|---|
| Fisher | TEST FULL (172 sessions) | 15.37 | Baseline (USM + Turn-to-Diarize)DiarizationLM-8b-Fisher-v2 (Llama 3 8B)DiarizationLM-Gemma-4-E4B-v1 (4B) |
5.32 [4.93, 5.74] 3.28 2.99 [2.65, 3.37] |
20.88 [19.97, 21.88] 18.37 17.62 [16.76, 18.56] |
0.215 [0.151, 0.291] — 0.093 [0.047, 0.145] |
— — -2.33% [-2.51, -2.16] (0/10,000 ≥ 0) |
| CALLHOME | TEST FULL (20 calls) | 15.22 | Baseline (USM + Turn-to-Diarize)DiarizationLM-8b-Fisher-v2 (Llama 3 8B)DiarizationLM-Gemma-4-E4B-v1 (4B) |
7.74 [6.07, 9.65] 6.66 4.92 [3.46, 6.75] |
24.31 [21.27, 27.43] 23.57 20.69 [17.98, 23.66] |
0.050 [0.000, 0.150] — 0.000 [0.000, 0.000] |
— — -2.82% [-3.48, -2.14] (0/10,000 ≥ 0) |
| ICSI | TEST FULL (3 meetings) | 29.42 | Baseline (USM + Turn-to-Diarize)DiarizationLM-Gemma-4-E4B-v1 (4B) |
14.70 [11.65, 20.29] 14.10 [10.77, 19.94] |
43.90 [39.10, 51.67] 43.32 [38.38, 51.20] |
0.333 [0.000, 1.000] 0.333 [0.000, 1.000] |
— -0.60% [-0.88, -0.35] (n = 3) |
| AMI | TEST WORD FULL (16 meetings) | 24.33 | Baseline (USM + Turn-to-Diarize)DiarizationLM-Gemma-4-E4B-v1 (4B) |
15.68 [10.64, 21.11] 14.89 [9.80, 20.38] |
40.32 [32.43, 48.00] 39.57 [31.57, 47.29] |
0.500 [0.188, 0.812] 0.438 [0.188, 0.750] |
— -0.79% [-1.00, -0.60] (0/10,000 ≥ 0) |
Installation
Install from PyPI
# Core package (ASR + ECAPA-TDNN + PyanNetSegmentation + FlaxSpeaker + DER/JER + TPST/LG-TPST)
pip install diarizers
# Recommended full installation (adds Qwen3-ForcedAligner-0.6B + GGUF CPU LLM + scikit-learn)
pip install "diarizers[align,audio,llm]"
(Optional fast CPU forced alignment: if audio.cpp's audiocpp_cli is on PATH or set via DIARIZERS_AUDIOCPP_CLI, Qwen3ForcedAligner(backend="auto") automatically runs qwen3-forced-aligner-0.6b-f16.gguf on CPU without requiring qwen-asr.)
Install from Source
git clone https://github.com/diarizers-community/diarizers.git
cd diarizers
pip install -e ".[align,audio,llm,dev]"
How to Run the Pipeline
1. One-Liner End-to-End Python API (DiarizersPipeline.from_pretrained)
Run the full pipeline on any WAV/MP3/FLAC file or 16 kHz NumPy waveform using a high-level profile ("best-quality", "max", "balanced", "fast", or "acoustic-only"):
import diarizers
# 1. Default ("best-quality"): Whisper-large-v3-turbo + Qwen3-ForcedAligner-0.6B +
# FlaxSpeaker-XL-Diar-Adapt + DiarizationLM-Gemma-4-12B-v1 (3.52% WDER, 22.82% Strict DER)
# On CPU, backend="auto" automatically uses Q4_K_M GGUF when llama-cpp-python is installed!
pipe = diarizers.DiarizersPipeline.from_pretrained()
# 2. Or select a quality / speed / hardware profile:
# - profile="max": XL-Diar-Adapt + ECAPA fusion + Qwen3-Align + 12B-v1 (3.47% WDER SOTA)
# - profile="balanced": 15x faster ECAPA + Qwen3-Align + 12B-v1 (3.54% WDER)
# - profile="fast": 2x faster LLM & ~7.6 GiB RAM (ECAPA + E4B-v2, aligner OFF by default)
# - profile="acoustic-only": ECAPA powerset_ward without LLM (<2 GiB RAM, 23.19% Strict DER)
pipe_fast = diarizers.DiarizersPipeline.from_pretrained(profile="fast")
# Override word_aligner explicitly if desired (e.g. disable on best-quality, or enable on fast):
pipe_fast_aligned = diarizers.DiarizersPipeline.from_pretrained(
profile="fast", word_aligner="qwen3"
)
# Pass num_speakers=2 if known, or num_speakers=None to auto-detect (1..10 speakers)
transcript = pipe("conversation.wav", num_speakers=None)
# Export in multiple standard formats:
print(transcript.to_diarized_text()) # "<speaker:1> hello ... <speaker:2> hi ..."
print(transcript.to_rttm(recording_id="session_01")) # Overlap-aware Hybrid RTTM (default)
print(transcript.to_rttm(recording_id="session_01", allow_overlap=False)) # Non-overlapping RTTM (7.27% NIST DER)
print(transcript.to_srt()) # SubRip (.srt) subtitles with [Speaker k]
print(transcript.to_vtt()) # WebVTT (.vtt) subtitles
To run on a CUDA GPU with 16-bit bfloat16 Hugging Face transformers weights (requires transformers>=5.0.0 for gemma4 architecture support):
pipe_gpu = diarizers.DiarizersPipeline.from_pretrained(
profile="max", # FlaxSpeaker-XL-Diar-Adapt + ECAPA Fusion + DiarizationLM-Gemma-4-12B-v1
device="cuda:0",
)
transcript = pipe_gpu("callhome_sample.wav", num_speakers=None)
2. Modular End-to-End Python API (DiarizationPipeline)
You can also customize each stage independently (for example, choosing among UNIVERSAL_AUTO_PRESET, FLAXSPEAKER_XL_PRESET, FLAXSPEAKER_LARGE_PRESET, FISHER_TELEPHONY_PRESET, CALLHOME_TELEPHONY_PRESET, AMI_MEETING_PRESET, MEETING_MULTISPK_PRESET, or setting diarization_mode="sliding_spectral"):
from diarizers import (
DiarizationLMRefiner,
DiarizationPipeline,
DiarizationPreset,
ECAPASpectralDiarizer,
WhisperWordASR,
)
preset = DiarizationPreset(
name="custom_meeting",
segmentation_model="pyannote/segmentation-3.0",
encoder_name="speechbrain/spkrec-ecapa-voxceleb", # Or "wq2012/univ_full_eres2conformer_xl"
diarization_mode="powerset_ward",
min_clusters=2,
max_clusters=8,
)
pipeline = DiarizationPipeline(
asr=WhisperWordASR("openai/whisper-large-v3-turbo", device="cpu"),
diarizer=ECAPASpectralDiarizer(preset=preset, device="cpu"),
llm_refiner=DiarizationLMRefiner(
model_path_or_repo="diarizers-community/DiarizationLM-Gemma-4-12B-v1",
backend="auto", # Auto-selects Q4_K_M GGUF on CPU when llama-cpp-python is installed
),
use_locality_gate=True,
)
result = pipeline("meeting.wav")
print(result.to_diarized_text())
3. Post-Processing Any Diarized Transcript with DiarizationLM
If you already have a diarized transcript from any ASR + diarization system (<speaker:1> ... <speaker:2> ...), you can refine its speaker labels directly using DiarizationLMRefiner (12B-v1 or E4B-v2) and locality_gated_speaker_transfer (LG-TPST) or transcript_preserving_speaker_transfer (TPST):
from diarizers import (
DiarizationLMRefiner,
create_diarized_text,
extract_text_and_spk,
)
hyp_diarized = (
"<speaker:1> hello how are you doing <speaker:2> today i am doing great "
"thanks what about <speaker:1> you i am doing well too"
)
refiner = DiarizationLMRefiner(
model_path_or_repo="diarizers-community/DiarizationLM-Gemma-4-12B-v1", # Or E4B-v2 for fast CPU
backend="auto", # Uses Q4_K_M GGUF on CPU or bfloat16 transformers on GPU
)
# High-level helper returning (raw_tpst_spk, lg_tpst_spk, raw_completions):
hyp_text, hyp_spk = extract_text_and_spk(hyp_diarized)
raw_tpst_spk, lg_tpst_spk, _ = refiner.refine_utterance(hyp_text, hyp_spk)
print("Refined (LG-TPST):", create_diarized_text(hyp_text.split(), lg_tpst_spk.split()))
print("Refined (Raw-TPST):", create_diarized_text(hyp_text.split(), raw_tpst_spk.split()))
4. Command-Line Interface (diarizers CLI & scripts/)
Installing diarizers registers the diarizers console script with five subcommands (run/infer, prepare-sft-data/prepare-data, train, export, evaluate):
# 1a. Best-quality default (Whisper + Qwen3-ForcedAligner + FlaxSpeaker-XL-Diar + Gemma-4-12B-v1):
diarizers run \
--audio conversation.wav \
--output-json output_transcript.json \
--output-rttm output_transcript.rttm \
--output-srt output_transcript.srt
# 1b. Fast / 16 GiB CPU laptop profile (ECAPA powerset_ward + Gemma-4-E4B-v2, ~2x faster LLM):
diarizers run --audio conversation.wav --profile fast --output-srt output_fast.srt
# 1c. Max SOTA GPU profile (Dual-Encoder Fusion + Qwen3-ForcedAligner + Gemma-4-12B-v1):
diarizers run --audio meeting.wav --profile max --device cuda:0 --output-rttm meeting.rttm
# 1d. Non-overlapping RTTM or disabling forced alignment explicitly:
diarizers run --audio call.wav --no-overlap --word-aligner none --output-rttm call.rttm
# 1e. Acoustic-only profile (<2 GiB RAM, no LLM):
diarizers run --audio conversation.wav --profile acoustic-only --output-rttm acoustic.rttm
# 2. Prepare SFT training prompts (hyp2ora + deg2ref + Locality-Preserving Oracle):
diarizers prepare-sft-data \
--input-json decoded_train_utterances.json \
--output-json sft_train_prompts.json \
--flavor both
# 3. Fine-tune DiarizationLM (Gemma-4-E4B) with PEFT LoRA:
diarizers train \
--train-json sft_train_prompts.json \
--model-name-or-path google/gemma-4-E4B \
--output-dir ./lora_ckpt
# 4. Merge LoRA Safetensors and optionally quantize Q4_K_M GGUF:
diarizers export \
--model-dir ./lora_ckpt \
--output-dir ./merged_hf \
--base-model google/gemma-4-E4B \
--output-gguf model-q4_k_m.gguf
# 5a. Evaluate micro WER, WDER, cpWER, and SpkCntMAE with 95% bootstrap CIs:
diarizers evaluate \
--input-json decoded_test_utterances.json \
--bootstrap-samples 1000 \
--output-json eval_metrics.json
# 5b. Evaluate exact continuous-time DER & JER from RTTM files (Strict or NIST ±0.25s collar):
diarizers evaluate \
--ref-rttm reference.rttm \
--hyp-rttm hypothesis.rttm \
--collar 0.25 \
--skip-overlap \
--output-json der_jer_metrics.json
Standalone scripts are also provided in scripts/:
python scripts/inference.py --audio conversation.wav --profile best-quality --output_json out.jsonpython scripts/inference.py --audio conversation.wav --profile fast --output_srt out_fast.srtpython scripts/prepare_data.py --input_json train_utts.json --output_json sft_train.jsonpython scripts/train.py --train_json sft_train.json --output_dir ./lora_ckptpython scripts/export_model.py --model_dir ./lora_ckpt --output_dir ./merged_hf --base_model google/gemma-4-E4B --output_gguf model-q4_k_m.ggufpython scripts/evaluate.py --input_json test_utts.json --bootstrap_samples 1000
5. Training & Exporting Custom DiarizationLM Models
You can fine-tune your own DiarizationLM model on custom domain data in three steps:
- Construct SFT Training Pairs (
diarizers.dataprep): Given a JSON file of utterances containinghyp_text,hyp_spk,ref_text, andref_spk,build_sft_datasetautomatically computes:hyp_spk_oracle: Exact Hungarian-optimal speaker labels transferred fromrefontohypvia Myers' bit-parallel Levenshtein (TPST).hyp_spk_locality_oracle: Locality-preserving oracle targets that teach the LLM to fix short turn-boundary and backchannel errors (1 <= L <= 5words) while preserving acoustic speaker anchors on long monologues (L >= 6words).ref_spk_degraded: Synthetically degraded speaker boundaries onref_text(deg2refflavor) for data augmentation.
- LoRA Supervised Fine-Tuning (
diarizers.train/scripts/train.py): Fine-tunesgoogle/gemma-4-E4Borgoogle/gemma-4-12Busing completion-only cross-entropy loss on 4,000-character prompt chunks formatted with Gemma-4 turn tags (<|turn>user\n{prompt} --> <turn|>\n<|turn>model\n{completion} [eod]). - Merge & Quantize to GGUF (
diarizers.export/scripts/export_model.py): Merges LoRA adapters into 16-bitbfloat16Safetensors and optionally invokesllama.cppto export a 4-bitQ4_K_MGGUF file for fast CPU inference.
6. Evaluating WER, WDER, cpWER, SpkCntMAE, DER, and JER
from diarizers import (
compute_corpus_metrics,
evaluate_der_jer,
evaluate_rttm_files,
)
# A. Word-level metrics (WER, WDER, cpWER, SpkCntMAE + paired bootstrap CIs)
utterances = [
{
"utterance_id": "call_01",
"hyp_text": "hello good morning how are you",
"hyp_spk": "1 1 1 2 2 2",
"hyp_spk_llm": "1 1 1 2 2 2",
"ref_text": "hello good morning how are you",
"ref_spk": "1 1 1 2 2 2",
}
]
metrics = compute_corpus_metrics(
utterances,
hyp_spk_field="hyp_spk_llm",
bootstrap_samples=1000,
)
print(f"WER: {metrics['WER'] * 100:.2f}% | WDER: {metrics['WDER'] * 100:.2f}%")
print(f"cpWER: {metrics['cpWER'] * 100:.2f}% | SpkCntMAE: {metrics['SpkCntMAE']:.3f}")
# B. Continuous-time DER & JER (exact pyannote.metrics / NIST md-eval parity)
strict = evaluate_rttm_files("ref.rttm", "hyp.rttm", collar_each_side=0.0, skip_overlap=False)
nist = evaluate_rttm_files("ref.rttm", "hyp.rttm", collar_each_side=0.25, skip_overlap=True)
print(f"Strict DER: {strict['DER(%)']:.2f}% | Strict JER: {strict['JER(%)']:.2f}%")
print(f"NIST DER: {nist['DER(%)']:.2f}% | NIST JER: {nist['JER(%)']:.2f}%")
7. Interactive CPU Demos (hf_space/app.py & hf_space/index.html)
Two hosted interactive Spaces are available on Hugging Face:
- End-to-End Audio Pipeline Demo:
https://huggingface.co/spaces/diarizers-community/diarizers— Upload or select multi-speaker conversation audio, switch betweenBest Quality(12B-v1),Max(FlaxSpeaker-XL + 12B-v1),Fast(E4B-v2), andAcoustic Only, and inspect the acoustic baseline, refined transcript, NIST RTTM, and SRT subtitles. - Text-Only DiarizationLM GGUF Demo:
https://huggingface.co/spaces/diarizers-community/DiarizationLM-GGUF— Paste any multilingual diarized transcript (<speaker:1> ... <speaker:2> ...), selectFast (Gemma-4-E4B-v2)orBest Quality (Gemma-4-12B-v1)(Q4_K_MGGUF), and stream speaker boundary refinement on CPU.
To launch the end-to-end audio Gradio demo locally on CPU:
pip install gradio
python hf_space/app.py
Data Format
All training and evaluation scripts use the standard DiarizationLM JSON format ({"utterances": [...]}), fully compatible with diarizationlm:
| Field | Description |
|---|---|
"utterance_id" |
Unique recording or session identifier string. |
"hyp_text" |
Space-joined sequence of normalized ASR hypothesis words. |
"hyp_spk" |
Space-joined sequence of 1-indexed integer speaker IDs for each word in hyp_text. |
"ref_text" |
Space-joined sequence of normalized ground-truth reference words. |
"ref_spk" |
Space-joined sequence of 1-indexed integer speaker IDs for each word in ref_text. |
"hyp_spk_oracle" |
(Optional / Auto-computed) Oracle speaker sequence for hyp_text computed via tpst_align(ref_text, ref_spk, hyp_text, hyp_spk). |
"ref_spk_degraded" |
(Optional / Auto-computed) Synthetically boundary-degraded speaker sequence for ref_text used for deg2ref training augmentation. |
Repository Structure
diarizers/
├── src/diarizers/
│ ├── __init__.py # Public API exports (v1.3.0)
│ ├── types.py # WordSegment, SpeakerTurn, DiarizedTranscript (Hybrid/Acoustic/Word RTTM, VTT, SRT, JSON)
│ ├── configs.py # PromptConfig, PipelineProfiles & acoustic DiarizationPresets
│ ├── forced_alignment.py # Qwen3ForcedAligner & AudioCppForcedAligner (Qwen3-ForcedAligner-0.6B + Levenshtein DP)
│ ├── spectral.py # SpectralClusterer, Ward auto-K, balanced centering & cosine EM
│ ├── flaxspeaker_encoder.py # Pure-PyTorch FlaxSpeaker SimAM-ERes2Conformer + Hybrid-PFAS encoder
│ ├── diarization.py # PyanNetSegmentation, SpeechBrainECAPATDNN, powerset_ward & overlap-aware RTTM decoding
│ ├── asr.py # WhisperWordASR (default openai/whisper-large-v3-turbo), AudioCppASR (Qwen3-ASR GGUF), PrecomputedASR
│ ├── alignment.py # assign_speakers_from_probs_with_map, fuse_frame_probs_with_llm, Myers TPST, LG-TPST
│ ├── dataprep.py # Dual-flavor (hyp2ora + deg2ref) + Locality-Preserving SFT builder
│ ├── llm.py # DiarizationLMRefiner (llama.cpp GGUF & HF Transformers)
│ ├── pipeline.py # End-to-end DiarizationPipeline & DiarizersPipeline orchestrators
│ ├── evaluation.py # Exact WER, WDER, cpWER, SpkCntMAE, continuous-time DER/JER & paired bootstrap 95% CIs
│ ├── train.py # LoRA / SFT training configuration & runner
│ ├── export.py # Safetensors merge & llama.cpp Q4_K_M GGUF export
│ └── cli.py # `diarizers` CLI entrypoint
├── scripts/
│ ├── prepare_data.py # SFT dataset preparation script
│ ├── train.py # PEFT LoRA fine-tuning script for Gemma-4-E4B
│ ├── export_model.py # LoRA merge & GGUF quantization script
│ ├── evaluate.py # WDER/cpWER & RTTM DER/JER benchmark evaluation CLI
│ └── inference.py # Standalone end-to-end inference CLI
├── hf_space/
│ ├── app.py # Interactive CPU Gradio end-to-end audio demo
│ ├── index.html # Interactive browser-executable end-to-end audio demo
│ ├── examples/ # Curated multi-speaker conversation examples & metadata
│ ├── README.md # Hugging Face Space metadata & documentation
│ └── requirements.txt # CPU Space dependencies
├── docs/
│ └── blog_post.md # Technical deep-dive blog post on diarizers & Gemma-4
└── tests/
└── test_diarizers.py # Comprehensive unit & regression test suite
Pretrained Models on Hugging Face
- DiarizationLM (Gemma 4, Multilingual, Safetensors +
Q4_K_MGGUF, Apache-2.0):- Default
best-quality/max/balanced(14.3 GiBCPU RAM / GPUbfloat16,3.47%–3.54%WDER):diarizers-community/DiarizationLM-Gemma-4-12B-v1 - Fast CPU
fastprofile (7.6 GiBCPU RAM,2×faster,4.13%WDER):diarizers-community/DiarizationLM-Gemma-4-E4B-v2 - Legacy v1 (
en-only):diarizers-community/DiarizationLM-Gemma-4-E4B-v1
- Default
- Word-Level Forced Aligner (Apache-2.0, Default in
best-quality,max&balanced):- PyTorch /
qwen-asr:Qwen/Qwen3-ForcedAligner-0.6B - CPU GGUF (
audio.cpp):audio-cpp/audio.cpp-gguf(qwen3-forced-aligner-0.6b-f16.gguf)
- PyTorch /
- Speaker Encoders (Standalone PyTorch, Apache-2.0):
- Default
best-quality&maxdiarization-adapted encoder (64.4M, segment-CMVN):wq2012/univ_full_eres2conformer_xl_diar_adapt - Compact diarization encoder (
36.3M,1.57×faster on CPU than XL):wq2012/univ_full_eres2conformer_v2_diar - Additional
FlaxSpeakerSimAM-ERes2Conformercheckpoints:wq2012/univ_full_eres2conformer_xl_diar_pfas,wq2012/univ_full_eres2conformer_xl_diar,wq2012/univ_full_eres2conformer_xl,wq2012/univ_full_eres2conformer_v2_large,wq2012/univ_full_eres2conformer_large - Fast CPU encoder (
balanced,fast,acoustic-only&maxfusion):speechbrain/spkrec-ecapa-voxceleb
- Default
- Fine-Tuned
pyannote/segmentation-3.0(PyanNet) Checkpoints (MIT):diarizers-community/speaker-segmentation-fine-tuned-callhome-engdiarizers-community/speaker-segmentation-fine-tuned-callhome-jpndiarizers-community/speaker-segmentation-fine-tuned-callhome-deudiarizers-community/speaker-segmentation-fine-tuned-callhome-spadiarizers-community/speaker-segmentation-fine-tuned-callhome-zho
Running Tests & Linter
bash run_tests.sh
Citation
If you found this repository useful, please consider citing this work, the DiarizationLM paper, and the underlying segmentation and clustering papers:
@misc{akesbi-diarizers,
author = {Kamil Akesbi and Quan Wang and Sanchit Gandhi},
title = {"Diarizers: A repository for speaker diarization and DiarizationLM post-processing"},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/diarizers-community/diarizers}}
}
@inproceedings{wang24h_interspeech,
title = {{DiarizationLM: Speaker Diarization Post-Processing with Large Language Models}},
author = {Quan Wang and Yiling Huang and Guanlong Zhao and Evan Clark and Wei Xia and Hank Liao},
year = {2024},
booktitle = {Interspeech 2024},
pages = {3754--3758},
doi = {10.21437/Interspeech.2024-209},
}
@inproceedings{bredin-pyannote,
author = {Hervé Bredin},
title = {"pyannote.audio 2.1 speaker diarization pipeline: principle, benchmark, and recipe"},
year = {2023},
booktitle = {Proc. INTERSPEECH 2023},
}
@inproceedings{xia2022turn,
title = {{Turn-to-Diarize}: Online Speaker Diarization Constrained by Transformer Transducer Speaker Turn Detection},
author = {Wei Xia and Han Lu and Quan Wang and Anshuman Tripathi and Yiling Huang and Ignacio Lopez Moreno and Hasim Sak},
booktitle = {Proc. ICASSP 2022},
pages = {8077--8081},
year = {2022},
}
@inproceedings{wang2018speaker,
title = {Speaker Diarization with {LSTM}},
author = {Quan Wang and Carlton Downey and Li Wan and Philip Andrew Mansfield and Ignacio Lopez Moreno},
booktitle = {Proc. ICASSP 2018},
pages = {5239--5243},
year = {2018},
}
Metadata
Release files for diarizers 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diarizers-1.3.0.tar.gz | 166.8 kB | Without provenance | Details for diarizers-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diarizers-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for diarizers-1.3.0-py3-none-any.whl |
Total release size: 278.1 kB
Release files / diarizers-1.3.0.tar.gz
| Download URL | diarizers-1.3.0.tar.gz |
|---|---|
| Size | 166.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
23d70379fb363073a995361a9a4dc8a11a5c2ad607dd7e8ae2013d5e8d37effb
|
|
BLAKE2b-256 checksum How to use checksums |
ded9da481a011428aa0ab02f9834143f30205e468fa2c8cb4ca243cd867871ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.18
|
Release files / diarizers-1.3.0-py3-none-any.whl
| Download URL | diarizers-1.3.0-py3-none-any.whl |
|---|---|
| Size | 111.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
49f50b2882fba344d92faf14304e8cf6219b9e6ea9eb069f3b6a65b78a61ef0d
|
|
BLAKE2b-256 checksum How to use checksums |
8639f83300502950df4d3c5cc9d4410acc1774c7a38ab0529bb50b4a20336356
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.18
|
Security for diarizers 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.