Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 1b6606996e959b1dd3ae4e73b7c2c0ce1d1a4a78
parent e3eb8fbefcc8300ddd2f7ec3ba11d6860e944f5d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 11 Nov 2026 04:55:52 -0500

diarization: hasVoiceprints with no engine.embeddingModel on the record still checks the model -- every voiceprint must name one and all of a record's voiceprints must agree on it

A record from sortformer or an engine replacement carries no embedding
model; before this its voiceprints were only checked for a non-empty name
each, so two models' vectors could stand as one complete fingerprint. Test:
one model -> complete; two models, an empty name or a missing one -> not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Diffstat:
Mcommon/lib/diarization.test.ts | 13+++++++++++++
Mcommon/lib/diarization.ts | 4++++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/common/lib/diarization.test.ts b/common/lib/diarization.test.ts @@ -178,6 +178,19 @@ test("hasVoiceprints: every embeddable speaker has a REAL centroid (192 finite n assert.equal(voiceprintsPossible(short), false); }); +test("hasVoiceprints with no model on the record: each voiceprint names one, and they all agree", () => { + const noModel = (voiceprints: unknown[]) => + record({ engine: { engine: "sortformer", model: "sf.gguf" }, voiceprints: voiceprints as never }); + assert.equal(hasVoiceprints(noModel([vp(0, REAL, "titanet.onnx"), vp(1, REAL, "titanet.onnx")])), true); + assert.equal(hasVoiceprints(noModel([vp(0, REAL, "titanet.onnx"), vp(1, REAL, "ecapa.onnx")])), false, "two models"); + assert.equal(hasVoiceprints(noModel([vp(0, REAL, "titanet.onnx"), vp(1, REAL, "")])), false, "an empty model"); + assert.equal( + hasVoiceprints(noModel([vp(0, REAL, "titanet.onnx"), { speaker: 1, seconds: 4, centroid: REAL }])), + false, + "a missing model", + ); +}); + test("voiceprints are outside the freshness identity: a sidecar without them is not stale", () => { const target = diarizationTarget({ segModel: "/m/model.onnx", embModel: "/m/titanet.onnx", threshold: 0.9 }); const engine = { engine: "sherpa-onnx", segmentationModel: "model.onnx", embeddingModel: "titanet.onnx", threshold: 0.9 }; diff --git a/common/lib/diarization.ts b/common/lib/diarization.ts @@ -188,6 +188,10 @@ export function hasVoiceprints( if (model && v.embeddingModel !== model) return false; bySpeaker.set(v.speaker, v); } + // With no model on the record (a sortformer record, an engine replacement), + // the voiceprints still say which model made them, and they must all say the + // same one: a cosine between two models' vectors means nothing. + if (new Set(record.voiceprints.map((v) => v.embeddingModel)).size > 1) return false; for (const t of record.turns) if (!bySpeaker.has(t.speaker)) return false; for (const [speaker, v] of bySpeaker) { if (embeddable.has(speaker) ? !isRealCentroid(v.centroid) : v.centroid !== null && !isRealCentroid(v.centroid)) {