Add voice error handling - speak errors aloud and continue session
Previously: API errors were silent, session stopped, user confused Now: Julia speaks error message, adds to transcript, keeps listening Changes: - Catch block now speaks error via TTS: "Sorry, I encountered an error: [msg]" - Error added to transcript (visible in chat history) - Session continues in listening state (doesn't stop on error) - User can try again immediately without restarting session UX improvement: graceful error recovery instead of silent failure contexts/VoiceContext.tsx:332-351
This commit is contained in:
parent
9422c32926
commit
8a6d9fa420
@ -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;
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user