Skip to main content

Crate diaric

Crate diaric 

Source
Expand description

diaric

The backend-free speaker-diarization core: clustering, PLDA, pipeline assembly, reconstruction, fbank DSP, score normalization and SIMD/mmap numeric ops — with no ONNX/Torch dependency.

§What this is

diaric is the sans-I/O, model-runtime-free half of the diarization pipeline. It holds everything that computes over already-produced tensors and audio — speaker clustering, PLDA projection, the offline diarization assembly, frame reconstruction / RTTM emission, the kaldi-compatible fbank feature extractor, adaptive score normalization, and the shared numeric kernels — but none of the ONNX Runtime (ort) or LibTorch (tch) model runners.

The segmentation and embedding model runners (SegmentModel, EmbedModel) and the streaming service layer live in the diarization crate, which depends on diaric. Consumers with their own inference path (CoreML, custom CUDA, captured tensors) can depend on diaric directly and never pull in a native ML runtime.

§Modules

ModuleWhat it does
clusterOffline AHC → VBx clustering, spectral fallback, Hungarian assignment, and the online greedy centroid matcher (FluidAudio SpeakerManager port).
pldaPLDA projection over WeSpeaker embeddings. Weights are embedded via include_bytes! (models/plda/*.bin).
pipelineassign_embeddings — the full AHC + VBx + centroid + constrained-Hungarian assignment stage.
offlinediarize_offline — batch pyannote-equivalent diarization over pre-computed (segmentation, raw-embedding) tensors.
aggregate / reconstructSpeaker counting and frame-level reconstruction → RTTM spans.
segmentThe sans-I/O Segmenter windowing/hysteresis state machine, powerset decoding, and option constants (the ONNX SegmentModel runner stays in diarization).
embedThe Embedding value types and the bit-exact torchaudio kaldi-fbank DSP (the ONNX EmbedModel runner stays in diarization).
score_normAdaptive score normalization (AS-Norm1). Rescales trial scores against a cohort distribution so one threshold means the same thing for every speaker. Generic over the score source — no embedding dimension in its surface.
ops / spillThree-tier (scalar / NEON / AVX2 / AVX-512) numeric primitives and the file-backed mmap spill backend for pathological-size inputs.
provenanceModel/PLDA identity metadata.

§Usage

Add diaric to your Cargo.toml:

[dependencies]
diaric = "0.2"

Enable serde for Serialize/Deserialize on the public *Options types.

§Cargo features

FeatureDefaultWhat it enables
serdenoSerialize/Deserialize impls for the public *Options types. Duration fields serialize as humantime strings (“250ms”, “1.5s”).
_benchnoInternal — exposes the crate-private ops numeric layer (plus ops::pdist_euclidean) to the benches/*.rs harnesses. ops is the only module it affects, and the only one outside the public API; cluster, pipeline, reconstruct and plda are public surface under semver.

There is deliberately no ort / tch / execution-provider feature: the model runners that need them are in diarization.

§License

diaric is offered under the composite SPDX expression

(MIT OR Apache-2.0) AND Apache-2.0 AND MIT AND CC-BY-4.0 AND BSD-2-Clause AND BSD-3-Clause

The (MIT OR Apache-2.0) branch is the original diaric code (caller’s choice); the remaining terms are mandatory obligations from the third-party components this core vendors as source ports or embedded data. See the LICENSE-APACHE, LICENSE-MIT, and NOTICE files for the full third-party attribution record.

§LICENSE-MAPPING — which term covers what

SPDX termComponent in diaricProvenance
MIT OR Apache-2.0The original diaric / diarization Rust code (caller’s choice).—
Apache-2.0cluster::online — the greedy online centroid matcher, a source port of FluidAudio’s SpeakerManager. A mandatory obligation, not the OR branch above: choosing MIT for the original code does not discharge it.FluidAudio (Apache-2.0), FluidInference Team.
MITThe offline cluster flow (AHC/VBx/spectral/centroid), pipeline, reconstruct, aggregate, the segment post-processing, and the PLDA math — algorithm ports of pyannote.audio.pyannote/pyannote-audio (MIT)
CC-BY-4.0models/plda/*.bin — PLDA weights embedded into the compiled binary via include_bytes! (src/plda/loader.rs). Attribution is required in any redistributed binary.pyannote/speaker-diarization-community-1; trained by BUT Speech@FIT. See models/plda/SOURCE.md.
BSD-2-Clausesrc/embed/fbank.rs — a port of torchaudio.compliance.kaldi.fbank (torchaudio 2.11). torchaudio is BSD-2-Clause.PyTorch/torchaudio (BSD-2-Clause), © 2017 Facebook Inc. (Soumith Chintala).
BSD-3-Clausesrc/cluster/hungarian/lsap.rs (a port of SciPy’s rectangular_lsap.cpp) and the scipy-derived PLDA eigenvector blobs (eigenvectors_desc, phi_desc).SciPy scipy.optimize (BSD-3-Clause).

Note on the adapted NOTICE. The NOTICE file is adapted from diarization’s — materially, not carried verbatim: its preamble is rewritten for diaric’s footprint and it adds the pyannote.audio source-port attribution (section 7). Its pyannote/segmentation-3.0 (bundled ONNX) and WeSpeaker entries describe models the diarization crate bundles or loads — diaric ships no ONNX/Torch model files. The only model artifact diaric embeds is the CC-BY-4.0 PLDA weight set above; a downstream binary linking diaric must reproduce that PLDA attribution and the source-port notices (pyannote, SciPy, torchaudio, FluidAudio).

Copyright (c) 2026 FinDIT studio authors.

Modules§

aggregate
Pyannote-equivalent Inference.aggregate primitives.
cluster
Speaker clustering — generic offline batch cluster_offline, the pyannote cluster_vbx-pipeline primitives (ahc, vbx, centroid, hungarian), and a streaming online engine.
embed
Speaker-embedding value types + the kaldi-compatible fbank DSP.
offline
Offline (non-streaming) diarization.
pipeline
Full pyannote-equivalent batch clustering pipeline.
plda
PLDA (Probabilistic Linear Discriminant Analysis) transform.
provenance
Model-identity accessors so a downstream pipeline reads the loaded model’s family + version instead of hardcoding them, giving each diarization result a reproducible record of which model artifacts (segmentation, embedding, clustering/PLDA) produced it.
reconstruct
Pyannote reconstruction stage: hard_clusters + segmentations + count → per-output-frame discrete diarization (binary (frames, clusters) grid).
score_norm
Adaptive score normalization (AS-Norm) over speaker-trial scores.
segment
Speaker segmentation: Sans-I/O state machine + powerset post-processing.
spill
Spill-buffer configuration types reachable from public API surfaces (e.g. OfflineInput::with_spill_options, AssignEmbeddingsInput and ReconstructInput).

Functions§

axpy_f32Non-_bench
f32 fused multiply-add primitive: y[i] += alpha * x[i] for each i.