From a3bcc5bee50f91b50c8ca7fa5c30ab81e8c3c922 Mon Sep 17 00:00:00 2001 From: Developer Date: Wed, 8 Apr 2026 12:15:43 -0700 Subject: [PATCH] Show transcription start errors in UI, improve error logging Start Transcription button now shows the error message when it fails instead of silently reverting. Common causes: - Missing PortAudio library on Linux - Audio device not accessible - Deepgram connection failure Also added error details to backend console output and captured the last error from the Deepgram engine for better diagnostics. Co-Authored-By: Claude Opus 4.6 (1M context) --- backend/app_controller.py | 9 ++++++++- client/deepgram_transcription.py | 2 ++ src/lib/components/Controls.svelte | 19 +++++++++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/backend/app_controller.py b/backend/app_controller.py index d45d1bc..d5265b1 100644 --- a/backend/app_controller.py +++ b/backend/app_controller.py @@ -396,7 +396,14 @@ class AppController: try: success = self.transcription_engine.start_recording() if not success: - return False, "Failed to start recording" + import logging + # Check if there's a recent error in the logger + err_detail = getattr(self.transcription_engine, '_last_error', '') + msg = f"Failed to start recording" + if err_detail: + msg += f": {err_detail}" + print(f"ERROR: {msg}") + return False, msg # Start server sync if enabled if self.config.get('server_sync.enabled', False): diff --git a/client/deepgram_transcription.py b/client/deepgram_transcription.py index ec49bad..68b05a5 100644 --- a/client/deepgram_transcription.py +++ b/client/deepgram_transcription.py @@ -167,6 +167,8 @@ class DeepgramTranscriptionEngine: self._start_audio_stream() except Exception as exc: logger.error("Failed to open audio stream: %s", exc) + print(f"ERROR: Failed to open audio stream: {exc}") + self._last_error = f"Audio stream error: {exc}" self._is_recording = False self._stop_event.set() return False diff --git a/src/lib/components/Controls.svelte b/src/lib/components/Controls.svelte index 0a52ad8..987ace0 100644 --- a/src/lib/components/Controls.svelte +++ b/src/lib/components/Controls.svelte @@ -8,9 +8,12 @@ ); let isLoading = $state(false); + let errorMessage = $state(""); + async function toggleTranscription() { if (isLoading) return; isLoading = true; + errorMessage = ""; try { if (isTranscribing) { await backendStore.apiPost("/api/stop"); @@ -20,8 +23,10 @@ // Poll status to update UI immediately instead of waiting // for WebSocket broadcast (which can be delayed or missed) await backendStore.pollStatus(); - } catch (err) { - console.error("Failed to toggle transcription:", err); + } catch (err: unknown) { + const msg = err instanceof Error ? err.message : String(err); + console.error("Failed to toggle transcription:", msg); + errorMessage = msg; } finally { isLoading = false; } @@ -104,9 +109,19 @@ + + {#if errorMessage} + {errorMessage} + {/if}