diff --git a/desktop/src/features/dictation/hooks/useRealtimeDictation.ts b/desktop/src/features/dictation/hooks/useRealtimeDictation.ts index 9e965a05b..07518e26a 100644 --- a/desktop/src/features/dictation/hooks/useRealtimeDictation.ts +++ b/desktop/src/features/dictation/hooks/useRealtimeDictation.ts @@ -8,6 +8,7 @@ import { BUFFER_COMMITTED_EVENT, TRANSCRIPT_COMPLETED_EVENT, TRANSCRIPT_DELTA_EVENT, + TRANSCRIPT_FAILED_EVENT, commitAudioBuffer, connectPeerConnection, createAudioBufferCapture, @@ -185,6 +186,13 @@ export function useRealtimeDictation({ return; } + if (event.type === TRANSCRIPT_FAILED_EVENT) { + console.warn("OpenAI transcription failed for item", event); + setIsTranscribing(false); + toast.error(event.error?.message ?? "Transcription failed"); + return; + } + if ( event.type !== TRANSCRIPT_DELTA_EVENT && event.type !== TRANSCRIPT_COMPLETED_EVENT && diff --git a/desktop/src/features/dictation/lib/realtimeAudio.ts b/desktop/src/features/dictation/lib/realtimeAudio.ts index 904134632..1ce20b0dd 100644 --- a/desktop/src/features/dictation/lib/realtimeAudio.ts +++ b/desktop/src/features/dictation/lib/realtimeAudio.ts @@ -8,6 +8,8 @@ export const TRANSCRIPT_DELTA_EVENT = "conversation.item.input_audio_transcription.delta"; export const TRANSCRIPT_COMPLETED_EVENT = "conversation.item.input_audio_transcription.completed"; +export const TRANSCRIPT_FAILED_EVENT = + "conversation.item.input_audio_transcription.failed"; export const BUFFER_COMMITTED_EVENT = "input_audio_buffer.committed"; const MAX_BUFFER_CHUNKS = 500; // ~10s at 20ms per chunk