aufklarer/Sortformer-Diarization-CoreML
Sortformer Diarization (CoreML)
CoreML port of NVIDIA Sortformer for end-to-end speaker diarization on Apple Silicon. Runs on the Neural Engine. No separate embedding extraction or clustering — the model directly predicts per-frame speaker activity for up to 4 speakers, with streaming state (speaker cache + FIFO) carried across calls.
Model
Three variants ship from the same checkpoint, differing only in chunk shape:
Files
Performance
Measured on M-series Apple Silicon (Neural Engine, warm):
The streaming export is parity-gated: driven by NeMo's own streaming feature loader and cache-update algorithm, it matches NeMo's native forward_streaming loop at 100% frame-decision agreement (MAE 0.0005). On a five-file VoxConverse-dev pilot, the incremental session reaches 8.1% DER (collar 0.25) with correct speaker counts on all files.
Streaming interface
The streaming variant carries state through the CoreML interface; the speaker-cache update runs host-side between calls.
Inputs: chunk [1,112,128], chunk_lengths [1], spkcache [1,188,512], spkcache_lengths [1], fifo [1,40,512], fifo_lengths [1]
Outputs: speaker_preds_out [1,242,4], chunk_pre_encoder_embs_out [1,14,512], chunk_pre_encoder_lengths_out [1]
The pipeline contains two sub-models: PreEncoder (mel pre-encode + state concat) and Head (FastConformer + Transformer + sigmoid heads).
Usage
// Whole-buffer diarization
let diarizer = try await SortformerDiarizer.fromPretrained()
let result = diarizer.diarize(audio: samples, sampleRate: 16000)
// Incremental streaming: push PCM in any size, stable speaker slots
let session = try await SortformerStreamingSession.fromPretrained()
let snapshot = try session.push(audio: samples)
let final = try session.finish()speech diarize meeting.wav --engine sortformerSource
- Upstream model: nvidia/diar_streaming_sortformer_4spk-v2.1 · Sortformer paper · Streaming Sortformer paper
- Upstream license: NVIDIA Open Model License (weights); this conversion is published under CC-BY-4.0 with attribution to NVIDIA.
Links
- speech-swift — Apple SDK
- Docs — install and CLI docs
- Guide — speaker diarization guide
- soniqo.audio — website
- blog — blog
