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
feat(transcribe): generate clientTranscriptionId for cloud sync dedup (#702)
Gabriel Stein698afe2942ab
diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.jsindex 0c200fb57..b68ad866a 100644--- a/src/helpers/audioManager.js+++ b/src/helpers/audioManager.js@@ -1376,6 +1376,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);limitReached: result.limitReached,wordsUsed: result.wordsUsed,wordsRemaining: result.wordsRemaining,+ clientTranscriptionId: result.clientTranscriptionId,};}@@ -1909,7 +1910,7 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);}}- async saveTranscription(text, rawText = null) {+ async saveTranscription(text, rawText = null, { clientTranscriptionId } = {}) {if (!getSettings().dataRetentionEnabled) {logger.debug("Skipping transcription save — data retention disabled", {}, "audio");this.lastAudioBlob = null;@@ -1918,7 +1919,9 @@ registerProcessor("pcm-streaming-processor", PCMStreamingProcessor);}try {- const result = await window.electronAPI.saveTranscription(text, rawText);+ const result = await window.electronAPI.saveTranscription(text, rawText, {+ clientTranscriptionId,+ });if (result?.id) syncService.debouncedPush("transcription", result.id);// Save audio if we have a captured blob and the transcription was saved successfullydiff --git a/src/helpers/database.js b/src/helpers/database.jsindex 7a9b9a541..e22b526fd 100644--- a/src/helpers/database.js+++ b/src/helpers/database.js@@ -548,13 +548,17 @@ class DatabaseManager {saveTranscription(text,rawText = null,- { status = "completed", errorMessage = null, errorCode = null } = {}+ {+ status = "completed",+ errorMessage = null,+ errorCode = null,+ clientTranscriptionId = randomUUID(),+ } = {}) {try {if (!this.db) {throw new Error("Database not initialized");}- const clientTranscriptionId = randomUUID();const stmt = this.db.prepare("INSERT INTO transcriptions (text, raw_text, status, error_message, error_code, client_transcription_id) VALUES (?, ?, ?, ?, ?, ?)");diff --git a/src/helpers/ipcHandlers.js b/src/helpers/ipcHandlers.jsindex 28fc974b5..0168eb2fc 100644--- a/src/helpers/ipcHandlers.js+++ b/src/helpers/ipcHandlers.js@@ -3388,6 +3388,9 @@ class IPCHandlers {if (!cookieHeader) throw new Error("No session cookies available");const audioData = Buffer.from(audioBuffer);+ // Reused for the local SQLite row so SyncService upserts the existing+ // cloud row (filling in text) instead of creating a duplicate.+ const clientTranscriptionId = crypto.randomUUID();const multipartFields = {language: opts.language,prompt: opts.prompt,@@ -3396,6 +3399,7 @@ class IPCHandlers {appVersion: app.getVersion(),clientVersion: app.getVersion(),sessionId: this.sessionId,+ clientTranscriptionId,};debugLogger.debug("Cloud transcribe request", { audioSize: audioData.length }, "cloud-api");@@ -3411,6 +3415,7 @@ class IPCHandlers {return {success: true,text,+ clientTranscriptionId,wordsUsed: lastResponse?.wordsUsed,wordsRemaining: lastResponse?.wordsRemaining,plan: lastResponse?.plan,@@ -3443,6 +3448,7 @@ class IPCHandlers {return {success: true,text: result.text,+ clientTranscriptionId,wordsUsed: result.wordsUsed,wordsRemaining: result.wordsRemaining,plan: result.plan,diff --git a/src/hooks/useAudioRecording.js b/src/hooks/useAudioRecording.jsindex 9eb1eca54..fa554a334 100644--- a/src/hooks/useAudioRecording.js+++ b/src/hooks/useAudioRecording.js@@ -158,7 +158,9 @@ export const useAudioRecording = (toast, options = {}) => {await navigator.clipboard.writeText(result.text);}- audioManagerRef.current.saveTranscription(result.text, result.rawText ?? result.text);+ audioManagerRef.current.saveTranscription(result.text, result.rawText ?? result.text, {+ clientTranscriptionId: result.clientTranscriptionId,+ });if (result.source === "openai" && getSettings().useLocalWhisper) {toast({diff --git a/src/types/electron.ts b/src/types/electron.tsindex 61c0c23f9..66540b2c5 100644--- a/src/types/electron.ts+++ b/src/types/electron.ts@@ -389,6 +389,7 @@ declare global {status?: TranscriptionStatus;errorMessage?: string | null;errorCode?: TranscriptionErrorCode;+ clientTranscriptionId?: string;}) => Promise<{ id: number; success: boolean; transcription?: TranscriptionItem }>;getTranscriptions: (limit?: number) => Promise<TranscriptionItem[]>;@@ -963,6 +964,7 @@ declare global {) => Promise<{success: boolean;text?: string;+ clientTranscriptionId?: string;wordsUsed?: number;wordsRemaining?: number;limitReached?: boolean;