fix(dictation): handle transcription failed events

OpenAI emits conversation.item.input_audio_transcription.failed when an
item cannot be transcribed (e.g. audio_unintelligible). Previously this
event was dropped by the type filter, leaving isTranscribing stuck true
with no user feedback after a preceding buffer commit.

Now the failed event is treated as terminal: clears the transcribing
indicator and surfaces the error message via toast.
This commit is contained in:
klopez4212
2026-07-11 16:18:39 +01:00
parent ed9cb0c29f
commit 1dcfbf25a2
2 changed files with 10 additions and 0 deletions
@@ -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 &&
@@ -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