How to diarize speech with pyannote.audio: run Community-1 locally
`pyannote.audio` is a PyTorch-based speech toolkit. This guide uses its pretrained `speaker-diarization-community-1` pipeline to estimate speaker turns in a recording. You need a Hugging Face account and access token to download the model files the first time, but Community-1 performs audio inference on your computer. Labels such as `SPEAKER_00` distinguish speakers within that recording; they do not identify real people. [Official repository guide](https://github.com/pyannote/pyannote-audio) · [Community-1 model card](https://huggingface.co/pyannote/speaker-diarization-community-1)
How to diarize speech with pyannote.audio: run Community-1 locally
pyannote.audio is a PyTorch-based speech toolkit. This guide uses its pretrained speaker-diarization-community-1 pipeline to estimate speaker turns in a recording. You need a Hugging Face account and access token to download the model files the first time, but Community-1 performs audio inference on your computer. Labels such as SPEAKER_00 distinguish speakers within that recording; they do not identify real people. Official repository guide · Community-1 model card
What do you need?
This guide reflects the official repository and Community-1 model card checked on November 20, 2026. pyannote.audio requires Python 3.11 or later, and the official quick start lists ffmpeg as an audio-decoding dependency. Follow the official FFmpeg installation guide for your operating system. A GPU is optional: the pipeline runs on the CPU by default and can be moved to a CUDA-enabled PyTorch environment. Memory use and runtime depend on recording length, model version, and hardware, so begin with a short sample. Current project configuration · Installation and quick start
Community-1 expects mono 16 kHz audio. The official pipeline downmixes stereo or multichannel audio by averaging channels and resamples other sample rates to 16 kHz when loading a file. This makes files easier to use, but does not preserve channel-specific speaker information. If different speakers were recorded on separate channels, inspect the original channels first and confirm that this conversion fits your analysis. Model card: input handling
You also need to accept the usage conditions for pyannote/speaker-diarization-community-1 on Hugging Face and create a read token. Store the token in an environment variable or a secret manager; do not put it in source code or a shared notebook. The model card lists the pipeline under CC BY 4.0. Before using it, check the current model-card terms and the obligations that apply to your intended use.
Install it and get a first result
The example assumes an active virtual environment and an installed ffmpeg. The project recommends uv add pyannote.audio and also documents pip install pyannote.audio. Official README
python -m pip install pyannote.audioSet your Hugging Face read token in an environment variable named HF_TOKEN, then save the code below as diarize.py. Replace audio.wav with your file. The first run needs an internet connection to download the model; once downloaded, Community-1 processes audio locally. Model usage guide
import os
from pyannote.audio import Pipeline
token = os.environ["HF_TOKEN"]
pipeline = Pipeline.from_pretrained(
"pyannote/speaker-diarization-community-1",
token=token,
)
# If the speaker count is unknown, first inspect the automatic estimate.
output = pipeline("audio.wav")
for turn, speaker in output.speaker_diarization:
print(f"{turn.start:.2f}–{turn.end:.2f}s {speaker}")The way you set HF_TOKEN depends on your operating system and shell. Avoid leaving a real token in a shared terminal, shell history, or source repository; use your system's secret-management method. If downloading the model fails with a 401 or 403 error, check that you accepted the model conditions, that the token belongs to the correct account, and that it has read access. Hugging Face token guide
Provide a speaker-count range when you know it
If you know the exact number of speakers, pass num_speakers to constrain the pipeline to that number. If you only know a range, pass min_speakers and max_speakers. For example, if an interview has two or three participants, use: Official model-card speaker-count options
output = pipeline("audio.wav", min_speakers=2, max_speakers=3)These options do not correct a wrong assumption. If the actual number falls outside the range or speakers sound very similar, the output can be wrong. Restrict the range only when you have independent information, such as an interview record or participant list. Otherwise, use the automatic estimate and review it manually.
Match overlapping speech with a transcript
output.speaker_diarization can include overlapping turns, so two speakers may appear at the same time. This preserves simultaneous speech. If your transcription system permits only one speaker at each moment, inspect output.exclusive_speaker_diarization. This separate output removes overlap, making it easier to reconcile fine-grained diarization timestamps with less precise transcript timestamps. Do not use the exclusive output alone when overlap matters to your analysis, because it removes that information. Community-1 exclusive output
for turn, speaker in output.exclusive_speaker_diarization:
print(f"{turn.start:.2f}–{turn.end:.2f}s {speaker}")The regular and exclusive outputs answer different questions. Use speaker_diarization to preserve overlap, or exclusive_speaker_diarization when you need to associate only one speaker with each transcription segment. Listen to important spans alongside the output.
Verify results and narrow down errors
The output is a model estimate of who spoke when. It does not identify people, and plausible timestamps do not guarantee that every turn is correct. Play several representative turns for each speaker. Check whether the same voice keeps the same label, whether boundaries match real speaker changes, and whether overlapping speech was missed or added. The model-card benchmark reports different results across datasets, so separately inspect sample recordings from your own domain. Official benchmarks and evaluation conditions
If the output looks wrong, check in this order:
Confirm that `audio.wav` opens and plays and that `ffmpeg` is installed.
If speakers are split into too many labels or merged, independently confirm the participant count and compare a run with `num_speakers` or a bounded range only when appropriate.
If overlap is the problem, inspect both regular and exclusive output. Exclusive diarization is not intended to preserve overlap.
For noisy recordings or speakers with similar voices, listen to the whole span, not just its boundaries. If errors recur in your domain, prepare a representative sample with human-assigned reference labels and evaluate it separately.
Local inference versus a hosted service
Community-1 can process audio locally after download. The separate precision-2 product can use a similar Python interface, but the official example runs it on pyannoteAI servers, meaning audio is sent to an external service. For sensitive recordings, review data transfer, account terms, and your organization's privacy policy first. The pyannote.audio FAQ also says the library does not support real-time streaming diarization by default. If you need real-time operation, assess a streaming-capable tool instead of assuming this offline-file workflow will work unchanged. Official README: local and hosted examples · FAQ
References
pyannote, [Official pyannote.audio README](https://github.com/pyannote/pyannote-audio)
pyannote, [Community-1 model card](https://huggingface.co/pyannote/speaker-diarization-community-1)
pyannote, [FAQ](https://github.com/pyannote/pyannote-audio/blob/main/FAQ.md)
pyannote.audio, [Python requirements and dependencies](https://github.com/pyannote/pyannote-audio/blob/main/pyproject.toml)