diff --git a/contexts/VoiceContext.tsx b/contexts/VoiceContext.tsx index b1a77bc..ddbce9f 100644 --- a/contexts/VoiceContext.tsx +++ b/contexts/VoiceContext.tsx @@ -335,10 +335,24 @@ export function VoiceProvider({ children }: { children: ReactNode }) { console.log('[VoiceContext] API request aborted'); return null; } + + // Handle API errors gracefully with voice feedback const errorMsg = err instanceof Error ? err.message : 'Unknown error'; console.warn('[VoiceContext] API error:', errorMsg); + + // Create user-friendly error message for TTS + const spokenError = `Sorry, I encountered an error: ${errorMsg}. Please try again.`; + + // Add error to transcript for chat display + addTranscriptEntry('assistant', spokenError); + + // Speak the error message + await speak(spokenError); + + // Don't set status to idle - return to listening after speaking error + // This keeps the voice session active + setError(errorMsg); - setStatus('idle'); return null; } },