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(parakeet): preserve newer streaming partial (#1283)
Henry Su090edc04edd2
diff --git a/src/helpers/parakeetWsResult.js b/src/helpers/parakeetWsResult.jsindex a916ac812..e95940e27 100644--- a/src/helpers/parakeetWsResult.js+++ b/src/helpers/parakeetWsResult.js@@ -13,6 +13,7 @@ function createOnlineAccumulator() {const finalizedSegments = new Set();let finalizedText = "";let partialText = "";+ let partialSegment = null;let fallbackKey = 0;const text = () =>@@ -33,6 +34,7 @@ function createOnlineAccumulator() {if (!parsed.is_final) {partialText = finalizedSegments.has(parsed.segment) ? "" : messageText;+ partialSegment = parsed.segment ?? null;return text();}@@ -41,7 +43,10 @@ function createOnlineAccumulator() {finalizedSegments.add(segment);finalizedText = finalizedText ? `${finalizedText} ${messageText}` : messageText;}- partialText = "";+ if (partialSegment === null || partialSegment === segment) {+ partialText = "";+ partialSegment = null;+ }return text();},text,diff --git a/test/helpers/parakeetWsResult.test.js b/test/helpers/parakeetWsResult.test.jsindex a583034fd..b0b71d3d6 100644--- a/test/helpers/parakeetWsResult.test.js+++ b/test/helpers/parakeetWsResult.test.js@@ -19,6 +19,27 @@ test("online sherpa messages keep finalized segments and latest partial", () =>);});+test("online sherpa duplicate final keeps a newer segment partial", () => {+ assert.equal(+ parseOnlineMessages([+ JSON.stringify({ text: "hello", is_final: true, segment: 0 }),+ JSON.stringify({ text: "new partial", is_final: false, segment: 1 }),+ JSON.stringify({ text: "hello", is_final: true, segment: 0 }),+ ]),+ "hello new partial"+ );+});++test("online sherpa matching final replaces its partial", () => {+ assert.equal(+ parseOnlineMessages([+ JSON.stringify({ text: "hello", is_final: false, segment: 0 }),+ JSON.stringify({ text: "hello world", is_final: true, segment: 0 }),+ ]),+ "hello world"+ );+});+test("online sherpa parser keeps numeric final text as text", () => {assert.equal(parseOnlineMessages([JSON.stringify({ text: "2026", is_final: true, segment: 0 })]),