mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user