Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
fix(transcription): relax speech gate thresholds and show no-audio toast
Gabriel Stein72ae30e8980b
diff --git a/src/helpers/localSpeechGate.js b/src/helpers/localSpeechGate.jsindex e999f494d..d9bd2f067 100644--- a/src/helpers/localSpeechGate.js+++ b/src/helpers/localSpeechGate.js@@ -1,9 +1,7 @@const SILENCE_RMS_THRESHOLD = 0.002;-const SPEECH_WINDOW_RMS_THRESHOLD = 0.0045;-const SPEECH_WINDOW_PEAK_THRESHOLD = 0.04;-const STRONG_SPEECH_RMS_THRESHOLD = 0.008;-const MIN_SPEECH_WINDOWS = 2;-const MIN_CONSECUTIVE_SPEECH_WINDOWS = 2;+const SPEECH_WINDOW_RMS_THRESHOLD = 0.003;+const SPEECH_WINDOW_PEAK_THRESHOLD = 0.02;+const STRONG_SPEECH_RMS_THRESHOLD = 0.006;export const createLocalSpeechGateState = () => ({peakRms: 0,@@ -55,10 +53,7 @@ export const getLocalSpeechGateDecision = (state) => {return { skip: true, reason: "silence", ...metrics };}- const hasSpeech =- state.speechWindowCount >= MIN_SPEECH_WINDOWS ||- state.maxConsecutiveSpeechWindows >= MIN_CONSECUTIVE_SPEECH_WINDOWS ||- (state.speechWindowCount >= 1 && state.peakRms >= STRONG_SPEECH_RMS_THRESHOLD);+ const hasSpeech = state.speechWindowCount >= 1 || state.peakRms >= STRONG_SPEECH_RMS_THRESHOLD;if (!hasSpeech) {return { skip: true, reason: "insufficient_speech", ...metrics };diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.jsindex 6a8557224..e9c2b4459 100644--- a/src/hooks/useAudioRecording.js+++ b/src/hooks/useAudioRecording.js@@ -123,6 +123,11 @@ export const useAudioRecording = (toast, options = {}) => {if (!transcribedText) {window.electronAPI?.hideDictationPreview?.();+ toast({+ title: t("hooks.audioRecording.noAudio.title"),+ description: t("hooks.audioRecording.noAudio.description"),+ variant: "default",+ });return;}diff --git a/test/helpers/localSpeechGate.test.js b/test/helpers/localSpeechGate.test.jsindex 05abbeb54..e523e80ee 100644--- a/test/helpers/localSpeechGate.test.js+++ b/test/helpers/localSpeechGate.test.js@@ -2,11 +2,8 @@ const test = require("node:test");const assert = require("node:assert/strict");test("treats near silence as skippable", async () => {- const {- createLocalSpeechGateState,- recordLocalSpeechWindow,- getLocalSpeechGateDecision,- } = await import("../../src/helpers/localSpeechGate.js");+ const { createLocalSpeechGateState, recordLocalSpeechWindow, getLocalSpeechGateDecision } =+ await import("../../src/helpers/localSpeechGate.js");const state = createLocalSpeechGateState();recordLocalSpeechWindow(state, 0.0012, 0.01);@@ -25,34 +22,29 @@ test("treats near silence as skippable", async () => {});test("rejects isolated noise bursts without sustained speech", async () => {- const {- createLocalSpeechGateState,- recordLocalSpeechWindow,- getLocalSpeechGateDecision,- } = await import("../../src/helpers/localSpeechGate.js");+ const { createLocalSpeechGateState, recordLocalSpeechWindow, getLocalSpeechGateDecision } =+ await import("../../src/helpers/localSpeechGate.js");const state = createLocalSpeechGateState();- recordLocalSpeechWindow(state, 0.0025, 0.03);- recordLocalSpeechWindow(state, 0.0052, 0.045);- recordLocalSpeechWindow(state, 0.0028, 0.028);+ // All windows have energy above silence but below speech thresholds+ recordLocalSpeechWindow(state, 0.0025, 0.015);+ recordLocalSpeechWindow(state, 0.0028, 0.018);+ recordLocalSpeechWindow(state, 0.0022, 0.014);const decision = getLocalSpeechGateDecision(state);assert.equal(decision.skip, true);assert.equal(decision.reason, "insufficient_speech");- assert.equal(decision.peakRms, 0.0052);- assert.equal(decision.peakAmplitude, 0.045);+ assert.equal(decision.peakRms, 0.0028);+ assert.equal(decision.peakAmplitude, 0.018);assert.equal(decision.windowCount, 3);- assert.equal(decision.speechWindowCount, 1);- assert.equal(decision.maxConsecutiveSpeechWindows, 1);+ assert.equal(decision.speechWindowCount, 0);+ assert.equal(decision.maxConsecutiveSpeechWindows, 0);});test("allows sustained speech-like energy through", async () => {- const {- createLocalSpeechGateState,- recordLocalSpeechWindow,- getLocalSpeechGateDecision,- } = await import("../../src/helpers/localSpeechGate.js");+ const { createLocalSpeechGateState, recordLocalSpeechWindow, getLocalSpeechGateDecision } =+ await import("../../src/helpers/localSpeechGate.js");const state = createLocalSpeechGateState();recordLocalSpeechWindow(state, 0.003, 0.025);@@ -65,7 +57,7 @@ test("allows sustained speech-like energy through", async () => {peakRms: 0.0061,peakAmplitude: 0.065,windowCount: 3,- speechWindowCount: 2,- maxConsecutiveSpeechWindows: 2,+ speechWindowCount: 3,+ maxConsecutiveSpeechWindows: 3,});});