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: wait for transcript before closing WebSocket on disconnect
Gabriel Stein9bc26ba113a6
diff --git a/src/helpers/openaiRealtimeStreaming.js b/src/helpers/openaiRealtimeStreaming.jsindex f5674123e..16c291237 100644--- a/src/helpers/openaiRealtimeStreaming.js+++ b/src/helpers/openaiRealtimeStreaming.js@@ -215,26 +215,24 @@ class OpenAIRealtimeStreaming {try {this.ws.send(JSON.stringify({ type: "input_audio_buffer.commit" }));} catch {}- }- let timeoutId;- const result = await Promise.race([- new Promise((resolve) => {- this.closeResolve = resolve;- this.ws.close();- }),- new Promise((resolve) => {- timeoutId = setTimeout(() => {- debugLogger.debug("OpenAI Realtime close timeout, using accumulated text");- resolve({ text: this.getFullTranscript() });+ const prevOnFinal = this.onFinalTranscript;+ await new Promise((resolve) => {+ const tid = setTimeout(() => {+ debugLogger.debug("OpenAI Realtime commit timeout, using accumulated text");+ this.onFinalTranscript = prevOnFinal;+ resolve();}, DISCONNECT_TIMEOUT_MS);- }),- ]);- clearTimeout(timeoutId);- this.closeResolve = null;- this.cleanup();- this.isDisconnecting = false;- return result;+ this.onFinalTranscript = (text) => {+ this.onFinalTranscript = prevOnFinal;+ prevOnFinal?.(text);+ clearTimeout(tid);+ resolve();+ };+ });+ }++ this.ws.close();}const result = { text: this.getFullTranscript() };