audio-frame-classification Β· audio Β· WASM Β· ~6 MB
Diarization answers a different question from "is someone talking?": it works out how many people are speaking and which of them is speaking at each moment β including where two voices overlap. This is pyannote's segmentation model, ~6 MB, running on the CPU in your browser, turning audio into a colour-coded speaker timeline with nothing uploaded.
| Model | onnx-community/pyannote-segmentation-3.0 (ONNX build of pyannote/segmentation-3.0) |
|---|---|
| Task | audio-frame-classification β speaker segmentation |
| Architecture | pyannote segmentation (SincNet + LSTM), 7-class powerset of up to 3 speakers |
| Output | Speaker-labelled segments (start, end, speaker id, confidence), incl. overlap |
| Params / dtype | ~1.5M Β· fp32 |
| Backend | WASM (CPU) β no GPU required; runs on mobile + desktop |
| Download | ~6 MB, cached after first load |
| License | MIT |
| Web APIs | Web Workers, WebAssembly, Web Audio (decoding) |
The model doesn't hear "words" β it slides over the audio and, for each short frame, classifies which combination of up to three speakers is active. Below is the raw per-frame activity it produced: grey = silence, indigo = one speaker, amber = overlapped speech. The timeline above is what you get after decoding those frames into speaker turns.
| Run diarization to see the segments. |
Diarization is the layer that turns a transcript into a conversation: it tells you who said what. Paired with a speech recogniser, it's how you get "Speaker 1: β¦ / Speaker 2: β¦" from a raw recording β and doing it on-device keeps the audio private.
Diarize a clip and read the speaker timeline β the core "who spoke when".
Talk-time analytics: how long each speaker held the floor, and overlap.
Record from your mic and diarize your own conversation live.
wav2vec2 transcribes β diarization attributes it to a speaker.
It's an audio-frame-classification model with a diarization post-processor. Decode
audio to the model's sample rate, run it, and let the processor turn the per-frame powerset logits
into speaker segments:
import { AutoProcessor, AutoModelForAudioFrameClassification, read_audio }
from "@huggingface/transformers";
const model_id = "onnx-community/pyannote-segmentation-3.0";
const model = await AutoModelForAudioFrameClassification.from_pretrained(model_id);
const processor = await AutoProcessor.from_pretrained(model_id);
const audio = await read_audio(url, processor.feature_extractor.config.sampling_rate); // 16 kHz mono
const inputs = await processor(audio);
const { logits } = await model(inputs); // [1, frames, 7] (powerset of up to 3 speakers)
const result = processor.post_process_speaker_diarization(logits, audio.length);
// [ [ { id: 0, start: 0, end: 1.05, confidence: 0.82 }, { id: 2, start: 1.05, end: 2.34, β¦ }, β¦ ] ]
This page runs exactly that in a Web Worker (decoding audio with Web Audio first), and draws the segments as a colour-coded speaker timeline.