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: resolve FFmpeg path in unpacked ASAR for local whisper.cpp transcription
Gabriel Stein3bae08f5998e
diff --git a/electron-builder.json b/electron-builder.jsonindex 4e84dc0dd..233ca9b26 100644--- a/electron-builder.json+++ b/electron-builder.json@@ -5,7 +5,7 @@"output": "dist"},"npmRebuild": true,- "buildDependenciesFromSource": true,+ "buildDependenciesFromSource": false,"files": ["main.js","preload.js",diff --git a/src/helpers/clipboard.js b/src/helpers/clipboard.jsindex 1538fc360..2d00028b1 100644--- a/src/helpers/clipboard.js+++ b/src/helpers/clipboard.js@@ -123,56 +123,89 @@ class ClipboardManager {async pasteWindows(originalClipboard) {return new Promise((resolve, reject) => {- let hasTimedOut = false;-- // -NoProfile: Skip loading user profile scripts (significant startup time savings)- // -NonInteractive: Prevent prompts that could hang execution- const pasteProcess = spawn("powershell", [- "-NoProfile",- "-NonInteractive",- "-Command",- 'Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SendKeys]::SendWait("^v")',- ]);+ // Reduce delay - clipboard.writeText is synchronous so no need to wait+ setTimeout(() => {+ let hasTimedOut = false;+ const startTime = Date.now();++ this.safeLog("πͺ Starting Windows paste operation...");++ // Optimized PowerShell command:+ // - Uses [void] to suppress output (faster)+ // - WindowStyle Hidden to prevent window flash+ // - ExecutionPolicy Bypass to skip policy checks+ // - Shorter variable names and compact syntax+ const pasteProcess = spawn("powershell.exe", [+ "-NoProfile",+ "-NonInteractive",+ "-WindowStyle",+ "Hidden",+ "-ExecutionPolicy",+ "Bypass",+ "-Command",+ // Optimized: Load assembly and send keys in one line, suppress output+ "[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms');[System.Windows.Forms.SendKeys]::SendWait('^v')",+ ]);++ let errorOutput = "";++ pasteProcess.stderr.on("data", (data) => {+ errorOutput += data.toString();+ });++ pasteProcess.on("close", (code) => {+ if (hasTimedOut) return;+ clearTimeout(timeoutId);++ const elapsed = Date.now() - startTime;++ if (code === 0) {+ this.safeLog(`β Windows paste completed successfully in ${elapsed}ms`);+ // Text pasted successfully - restore original clipboard+ // Use shorter delay since paste is already complete+ setTimeout(() => {+ clipboard.writeText(originalClipboard);+ this.safeLog("π Original clipboard content restored");+ }, 50);+ resolve();+ } else {+ this.safeLog(+ `β Windows paste failed with code ${code} after ${elapsed}ms`,+ errorOutput+ );+ reject(+ new Error(+ `Windows paste failed with code ${code}. Text is copied to clipboard - please paste manually with Ctrl+V.`+ )+ );+ }+ });- pasteProcess.on("close", (code) => {- if (hasTimedOut) return;- clearTimeout(timeoutId);-- if (code === 0) {- // Text pasted successfully- setTimeout(() => {- clipboard.writeText(originalClipboard);- }, PASTE_DELAY_MS);- resolve();- } else {+ pasteProcess.on("error", (error) => {+ if (hasTimedOut) return;+ clearTimeout(timeoutId);+ const elapsed = Date.now() - startTime;+ this.safeLog(`β Windows paste error after ${elapsed}ms:`, error.message);reject(new Error(- `Windows paste failed with code ${code}. Text is copied to clipboard - please paste manually with Ctrl+V.`+ `Windows paste failed: ${error.message}. Text is copied to clipboard - please paste manually with Ctrl+V.`));- }- });-- pasteProcess.on("error", (error) => {- if (hasTimedOut) return;- clearTimeout(timeoutId);- reject(- new Error(- `Windows paste failed: ${error.message}. Text is copied to clipboard - please paste manually with Ctrl+V.`- )- );- });+ });- const timeoutId = setTimeout(() => {- hasTimedOut = true;- killProcess(pasteProcess, "SIGKILL");- pasteProcess.removeAllListeners();- reject(- new Error(- "Paste operation timed out. Text is copied to clipboard - please paste manually with Ctrl+V."- )- );- }, 3000);+ const timeoutId = setTimeout(() => {+ hasTimedOut = true;+ const elapsed = Date.now() - startTime;+ this.safeLog(`β±οΈ Windows paste operation timed out after ${elapsed}ms`);+ killProcess(pasteProcess, "SIGKILL");+ pasteProcess.removeAllListeners();+ reject(+ new Error(+ "Paste operation timed out. Text is copied to clipboard - please paste manually with Ctrl+V."+ )+ );+ }, 5000);+ }, 10); // Reduced from PASTE_DELAY_MS (50ms) to 10ms - clipboard write is synchronous});}diff --git a/src/helpers/whisper.js b/src/helpers/whisper.jsindex 4369a1d0f..d0bfc5e53 100644--- a/src/helpers/whisper.js+++ b/src/helpers/whisper.js@@ -95,16 +95,29 @@ class WhisperManager {path.join(__dirname, "..", "..", "resources", "bin", genericBinaryName));- debugLogger.log("Checking whisper.cpp binary candidates:", candidates);-for (const candidate of candidates) {if (fs.existsSync(candidate)) {- debugLogger.log("Found whisper.cpp binary at:", candidate);- return candidate;+ try {+ const stats = fs.statSync(candidate);+ debugLogger.debug("Found whisper.cpp binary", {+ path: candidate,+ size: stats.size,+ });+ return candidate;+ } catch (statError) {+ debugLogger.warn("Binary exists but cannot be accessed", {+ path: candidate,+ error: statError.message,+ });+ }}}- debugLogger.log("No whisper.cpp binary found in any candidate path");+ debugLogger.warn("whisper.cpp binary not found", {+ platform,+ arch,+ searchedPaths: candidates,+ });return null;}@@ -417,9 +430,14 @@ class WhisperManager {whisperProcess.on("close", (exitCode) =>settle(resolve, { code: exitCode, stderr: stderrData }));- whisperProcess.on("error", (err) =>- settle(reject, new Error(`Whisper process error: ${err.message}`))- );+ whisperProcess.on("error", (err) => {+ debugLogger.error("Whisper process spawn failed", {+ error: err.code || err.message,+ binaryPath,+ binaryExists: fs.existsSync(binaryPath),+ });+ settle(reject, new Error(`Failed to start whisper.cpp: ${err.message}`));+ });});debugLogger.logWhisperPipeline("Process closed", {@@ -798,22 +816,23 @@ class WhisperManager {ffmpegPath += ".exe";}+ // Try unpacked ASAR path first (production builds unpack ffmpeg-static)+ const unpackedPath = ffmpegPath.replace(/app\.asar([/\\])/, "app.asar.unpacked$1");+ if (fs.existsSync(unpackedPath)) {+ debugLogger.debug("Found FFmpeg in unpacked ASAR", { path: unpackedPath });+ this.cachedFFmpegPath = unpackedPath;+ return unpackedPath;+ }++ // Try original path (development or if not in ASAR)if (fs.existsSync(ffmpegPath)) {if (process.platform !== "win32") {fs.accessSync(ffmpegPath, fs.constants.X_OK);}+ debugLogger.debug("Found FFmpeg at bundled path", { path: ffmpegPath });this.cachedFFmpegPath = ffmpegPath;return ffmpegPath;}-- // Try unpacked ASAR path- if (process.env.NODE_ENV !== "development") {- const unpackedPath = ffmpegPath.replace(/app\.asar([/\\])/, "app.asar.unpacked$1");- if (fs.existsSync(unpackedPath)) {- this.cachedFFmpegPath = unpackedPath;- return unpackedPath;- }- }} catch {// Bundled FFmpeg not available}