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
cleanup: more detailed logging
Gabriel Steinda0c05847cd0
diff --git a/main.js b/main.jsindex a36b5ce37..026c5a5d7 100644--- a/main.js+++ b/main.js@@ -994,6 +994,15 @@ ipcMain.handle('transcribe-local-whisper', async (event, audioBlob, options = {}if (code === 0) {try {const result = JSON.parse(stdout);++ // Check if the transcription is empty or just whitespace+ if (!result.text || result.text.trim().length === 0) {+ console.log('π No meaningful audio content detected (empty transcription)');+ event.sender.send('no-audio-detected');+ resolve({ success: false, message: 'No audio detected' });+ return;+ }+console.log('β Whisper transcription successful:', result.text?.substring(0, 50) + '...');resolve(result);} catch (parseError) {@@ -1001,9 +1010,15 @@ ipcMain.handle('transcribe-local-whisper', async (event, audioBlob, options = {}reject(new Error(`Failed to parse Whisper output: ${parseError.message}`));}} else {- console.error('β Whisper process failed with code:', code);- console.error('Stderr:', stderr);- reject(new Error(`Whisper transcription failed (code ${code}): ${stderr}`));+ if (stderr.includes('no audio') || stderr.includes('empty')) {+ console.log('π No audio content detected');+ event.sender.send('no-audio-detected'); // Could trigger a tooltip in the UI+ resolve({ success: false, message: 'No audio detected' });+ } else {+ console.error('β Whisper process failed with code:', code);+ console.error('Stderr:', stderr);+ reject(new Error(`Whisper transcription failed (code ${code}): ${stderr}`));+ }}});diff --git a/src/App.jsx b/src/App.jsxindex 1152bee15..1075535b0 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -164,6 +164,10 @@ export default function App() {} else {setError('No text transcribed. Try again.');}+ } else if (result.success === false && result.message === 'No audio detected') {+ // Handle no audio detected case - don't show as error, just a brief message+ setError('No audio detected');+ return; // Don't attempt fallback for no audio} else {throw new Error(result.error || 'Local Whisper transcription failed');}@@ -171,7 +175,7 @@ export default function App() {} catch (err) {console.error("Local Whisper error:", err);// Check if we should attempt fallback to OpenAI API- const allowFallback = localStorage.getItem('allowOpenAIFallback') !== 'false';+ const allowFallback = localStorage.getItem('allowOpenAIFallback') === 'true';if (allowFallback) {setError('Local Whisper failed. Retrying with OpenAI API...');diff --git a/src/components/SettingsPage.tsx b/src/components/SettingsPage.tsxindex 9c4689670..968ef0019 100644--- a/src/components/SettingsPage.tsx+++ b/src/components/SettingsPage.tsx@@ -116,6 +116,7 @@ export default function SettingsPage({ onClose }) {const [apiKey, setApiKey] = useState("");const [useLocalWhisper, setUseLocalWhisper] = useState(false);const [whisperModel, setWhisperModel] = useState("base");+ const [allowOpenAIFallback, setAllowOpenAIFallback] = useState(false);const [history, setHistory] = useState<TranscriptionItem[]>([]);const [isLoading, setIsLoading] = useState(true);const [whisperInstalled, setWhisperInstalled] = useState(false);@@ -137,8 +138,10 @@ export default function SettingsPage({ onClose }) {// Load Whisper settingsconst savedUseLocal = localStorage.getItem("useLocalWhisper") === "true";const savedModel = localStorage.getItem("whisperModel") || "base";+ const savedAllowFallback = localStorage.getItem("allowOpenAIFallback") === "true";setUseLocalWhisper(savedUseLocal);setWhisperModel(savedModel);+ setAllowOpenAIFallback(savedAllowFallback);// Load API key from main process first, then fallback to localStorageconst loadApiKey = async () => {@@ -322,10 +325,17 @@ export default function SettingsPage({ onClose }) {const saveWhisperSettings = () => {localStorage.setItem("useLocalWhisper", useLocalWhisper.toString());localStorage.setItem("whisperModel", whisperModel);+ localStorage.setItem("allowOpenAIFallback", allowOpenAIFallback.toString());++ // Also save API key if fallback is enabled and key is provided+ if (allowOpenAIFallback && apiKey.trim()) {+ localStorage.setItem("openaiApiKey", apiKey);+ }+alert(`Whisper settings saved! ${useLocalWhisper- ? `Using local model: ${whisperModel}`+ ? `Using local model: ${whisperModel}${allowOpenAIFallback ? ' with OpenAI fallback' : ''}`: "Using OpenAI API"}`);@@ -660,6 +670,70 @@ export default function SettingsPage({ onClose }) {</p></div>+ {/* OpenAI Fallback Toggle */}+ <div className="space-y-3">+ <div className="flex items-center justify-between">+ <label className="text-sm font-medium text-purple-800">+ Fall back to OpenAI API+ </label>+ <label className="relative inline-flex items-center cursor-pointer">+ <input+ type="checkbox"+ className="sr-only"+ checked={allowOpenAIFallback}+ onChange={(e) => setAllowOpenAIFallback(e.target.checked)}+ />+ <div className={`w-11 h-6 bg-gray-200 rounded-full peer peer-focus:ring-2 peer-focus:ring-purple-300 ${allowOpenAIFallback ? 'bg-purple-600' : 'bg-gray-300'} transition-colors duration-200`}>+ <div className={`absolute top-0.5 left-0.5 bg-white border border-gray-300 rounded-full h-5 w-5 transition-transform duration-200 ${allowOpenAIFallback ? 'translate-x-5' : 'translate-x-0'}`}></div>+ </div>+ </label>+ </div>+ <p className="text-xs text-purple-700">+ If local processing fails, try OpenAI API as backup+ </p>++ {/* API Key field - only show if fallback is enabled */}+ {allowOpenAIFallback && (+ <div className="p-3 bg-purple-50 border border-purple-200 rounded-lg">+ <label className="block text-sm font-medium text-purple-800 mb-2">+ OpenAI API Key (for fallback)+ </label>+ <div className="flex gap-2">+ <Input+ type="password"+ placeholder="sk-..."+ value={apiKey}+ onChange={(e) => setApiKey(e.target.value)}+ className="flex-1 text-sm border-purple-300 focus:border-purple-500"+ />+ <Button+ variant="outline"+ size="sm"+ onClick={async () => {+ try {+ const text = await window.electronAPI.readClipboard();+ if (text && text.trim()) {+ setApiKey(text.trim());+ } else {+ const webText = await navigator.clipboard.readText();+ setApiKey(webText.trim());+ }+ } catch (err) {+ alert("Could not paste from clipboard.");+ }+ }}+ className="border-purple-300 text-purple-700 hover:bg-purple-50"+ >+ Paste+ </Button>+ </div>+ <p className="text-xs text-purple-600 mt-1">+ Only used if local processing fails+ </p>+ </div>+ )}+ </div>+<div className="bg-white border border-purple-200 rounded-lg overflow-hidden">{/* Download Progress Bar */}{downloadingModel && (