Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(stt): filter singleton invalid VAD intervals and missing end segments
CyberSparkx8bf608278435
diff --git a/electron/stt/whisperServer.test.ts b/electron/stt/whisperServer.test.tsindex bcd035733..314926e58 100644--- a/electron/stt/whisperServer.test.ts+++ b/electron/stt/whisperServer.test.ts@@ -778,6 +778,30 @@ describe("WhisperServerManager", () => {}});+ it("filters out /vad segments missing end that map to zero-length intervals", async () => {+ const fakeJson = {+ segments: [+ { start: 1.5 }, // missing end -> maps to startSec: 1.5, endSec: 1.5+ ],+ };+ vi.stubGlobal(+ "fetch",+ vi.fn(async () => new Response(JSON.stringify(fakeJson), { status: 200 })),+ );+ try {+ const mgr = new WhisperServerManager();+ (mgr as unknown as { process: unknown; port: number; vadAvailable: boolean }).process = {};+ (mgr as unknown as { process: unknown; port: number; vadAvailable: boolean }).port = 9999;+ (mgr as unknown as { process: unknown; port: number; vadAvailable: boolean }).vadAvailable =+ true;++ const segments = await mgr.detectVadSegments({ samples: new Float32Array(1600) });+ expect(segments).toEqual([]);+ } finally {+ vi.unstubAllGlobals();+ }+ });+it("handles malformed WAV /vad HTTP 400 without crashing helper availability", async () => {vi.stubGlobal("fetch",@@ -844,6 +868,11 @@ describe("WhisperServerManager", () => {];expect(mergeVadIntervals(input)).toEqual([{ startSec: 3, endSec: 4 }]);});++ it("drops singleton intervals where endSec <= startSec", () => {+ expect(mergeVadIntervals([{ startSec: 2, endSec: 1 }])).toEqual([]);+ expect(mergeVadIntervals([{ startSec: 2, endSec: 2 }])).toEqual([]);+ });});it("chunks long audio across MAX_VAD_CHUNK_SAMPLES and offsets timestamps", async () => {diff --git a/electron/stt/whisperServer.ts b/electron/stt/whisperServer.tsindex fc58aec51..a9698674f 100644--- a/electron/stt/whisperServer.ts+++ b/electron/stt/whisperServer.ts@@ -723,7 +723,7 @@ export const MAX_VAD_CHUNK_SAMPLES = 16_000 * 180;* Merges contiguous or overlapping speech segments into non-overlapping intervals.*/export function mergeVadIntervals(segments: SttVadSegment[]): SttVadSegment[] {- if (segments.length <= 1) return segments;+ if (segments.length <= 1) return segments.filter((seg) => seg.endSec > seg.startSec);const merged: SttVadSegment[] = [];for (const seg of segments) {if (seg.endSec <= seg.startSec) continue;