Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix: tune speaker diarization thresholds to prevent excessive speaker creation

Gabriel Stein08171524d143
diff --git a/src/helpers/diarization.js b/src/helpers/diarization.js
index f9ed79380..6a9f6a57a 100644
--- a/src/helpers/diarization.js
+++ b/src/helpers/diarization.js
@@ -303,7 +303,7 @@ class DiarizationManager {
}
async diarize(wavPath, options = {}) {
- const { numSpeakers = -1, threshold = 0.5 } = options;
+ const { numSpeakers = -1, threshold = 0.35 } = options;
const binaryPath = this.getBinaryPath();
if (!binaryPath) {
diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.js
index 661730e9d..296ff231d 100644
--- a/src/helpers/ipcHandlers.js
+++ b/src/helpers/ipcHandlers.js
@@ -6080,7 +6080,7 @@ class IPCHandlers {
);
const similarity = speakerEmbeddings.cosineSimilarity(profileEmb, speakerEmb);
- if (similarity > 0.7) {
+ if (similarity > 0.6) {
this.databaseManager.setSpeakerMapping(
noteId,
emb.speaker_id,
@@ -6188,7 +6188,7 @@ class IPCHandlers {
}
}
- if (!bestEntry || bestSimilarity <= 0.7) {
+ if (!bestEntry || bestSimilarity <= 0.6) {
continue;
}
@@ -6267,6 +6267,12 @@ class IPCHandlers {
observedSpeakerIds.add(speakerId);
}
+ if (observedSpeakerIds.size > 10) {
+ debugLogger.warn("Excessive speaker count from live identification", {
+ observedSpeakers: observedSpeakerIds.size,
+ });
+ }
+
const expectedSpeakerCount =
observedSpeakerIds.size >= 2 ? Math.min(observedSpeakerIds.size, 4) : -1;
const diarizationSegments = await this.diarizationManager.diarize(
@@ -6312,7 +6318,7 @@ class IPCHandlers {
for (const spk of speakerIds) {
const segs = diarizationSegments.filter((s) => s.speaker === spk);
- const sorted = segs.sort((a, b) => b.end - b.start - (a.end - a.start)).slice(0, 3);
+ const sorted = segs.sort((a, b) => (b.end - b.start) - (a.end - a.start)).slice(0, 3);
const embeddings = [];
for (const seg of sorted) {
if (seg.end - seg.start < 1.5) continue;
@@ -6366,7 +6372,7 @@ class IPCHandlers {
}
}
- if (bestProfile && bestSim > 0.7) {
+ if (bestProfile && bestSim > 0.6) {
for (const seg of enrichedSegments) {
if (seg.speaker === mappedId) {
applyConfirmedSpeaker(seg, {
@@ -6377,7 +6383,7 @@ class IPCHandlers {
});
}
}
- } else if (bestProfile && bestSim > 0.55) {
+ } else if (bestProfile && bestSim > 0.5) {
for (const seg of enrichedSegments) {
if (seg.speaker === mappedId) {
if (isSpeakerLocked(seg)) {
diff --git a/src/helpers/liveSpeakerIdentifier.js b/src/helpers/liveSpeakerIdentifier.js
index fd3ad6c0a..a066583da 100644
--- a/src/helpers/liveSpeakerIdentifier.js
+++ b/src/helpers/liveSpeakerIdentifier.js
@@ -5,7 +5,7 @@ const { downsample24kTo16k } = require("../utils/audioUtils");
const SAMPLE_RATE = 16000;
const VAD_WINDOW_SIZE = 512;
-const MIN_SEGMENT_SECONDS = 0.8;
+const MIN_SEGMENT_SECONDS = 1.5;
const MIN_SEGMENT_SAMPLES = Math.round(SAMPLE_RATE * MIN_SEGMENT_SECONDS);
const LIVE_IDENTIFICATION_MIN_SECONDS = 1.6;
const LIVE_IDENTIFICATION_MIN_SAMPLES = Math.round(SAMPLE_RATE * LIVE_IDENTIFICATION_MIN_SECONDS);
@@ -15,9 +15,9 @@ const LIVE_IDENTIFICATION_INTERVAL_SAMPLES = Math.round(
);
const SPEECH_THRESHOLD = 0.15;
const SILENCE_THRESHOLD = 0.08;
-const SILENCE_WINDOWS_TO_END = 16;
-const MATCH_THRESHOLD = 0.82;
-const MATCH_MARGIN = 0.04;
+const SILENCE_WINDOWS_TO_END = 24;
+const MATCH_THRESHOLD = 0.65;
+const MATCH_MARGIN = 0.03;
const LIVE_WINDOW_PADDING_SECONDS = 0.75;
const DEFAULT_VAD_STATE_SHAPE = [2, 1, 64];
diff --git a/src/hooks/useMeetingTranscription.ts b/src/hooks/useMeetingTranscription.ts
index 59cfd2def..cf4cc90e0 100644
--- a/src/hooks/useMeetingTranscription.ts
+++ b/src/hooks/useMeetingTranscription.ts
@@ -72,7 +72,7 @@ const MEETING_MIC_PRIMARY_AUDIO_CONSTRAINTS = {
const REALTIME_MODELS = new Set(["gpt-4o-mini-transcribe", "gpt-4o-transcribe"]);
const SPEAKER_IDENTIFICATION_RETENTION_MS = 30_000;
-const SYSTEM_SPEAKER_CARRY_FORWARD_MS = 2_500;
+const SYSTEM_SPEAKER_CARRY_FORWARD_MS = 8_000;
const buildTranscriptText = (segments: TranscriptSegment[]) =>
segments
.map((segment) => segment.text)
@@ -508,7 +508,7 @@ export function useMeetingTranscription(): UseMeetingTranscriptionReturn {
nowMs - candidate.timestamp <= SYSTEM_SPEAKER_CARRY_FORWARD_MS
);
- if (previousSystemSegment?.speaker && previousSystemSegment.speakerIsPlaceholder) {
+ if (previousSystemSegment?.speaker) {
reserveSpeakerIndex(previousSystemSegment.speaker);
return normalizeTranscriptSegment({
...segment,