Transcripts and turn detection
An utterance is the audio segment finalized by a manual commit, server VAD, or the automatic duration boundary. Each utterance has an item_id and can produce partial results followed by a completed transcript.
Update the transcript
Each partial is the entire current hypothesis. Replace the previous text for that item_id; do not append it.
For example, earlier words may be revised as the utterance becomes clearer:
Store the completed result as authoritative, even if it differs from the last partial. This handler keeps each utterance separate:
Pass this handler as on_event=handle_transcript to the Python streaming example. A completed result may arrive without preceding partials and may contain an empty transcript if no speech was recognized.
Manual commit
Use manual commit when your application knows the boundary—for example, when a user releases a push-to-talk button. This is the default when turn_detection is omitted or null.
After sending the utterance’s audio, send a commit. An optional event_id lets you associate the acknowledgement with your request:
committed acknowledges the audio boundary; completed delivers the transcript. Wait for the completed result with the acknowledged item_id before marking that utterance finished.
If no audio is pending, the server returns input_audio_buffer.commit_empty. Do not wait for a new completed result for that commit. Previously committed utterances can still have final results pending.
Transcribe multiple utterances
Save this alongside stt_stream.py. Each recording contains one utterance in raw 16 kHz PCM16 mono. The source yields None after each file to send a manual commit while the receiver continues handling results.
The receiver tracks each acknowledged item_id until its completed result arrives. An empty final commit does not end the receiver while earlier results are pending.
A completed result leaves the connection open for another utterance. Track pending results by item_id when sending more audio, and close only after receiving all final results you need.
Automatic turn detection
Use server voice activity detection (VAD) when you want silence to end an utterance. Set turn_detection in the initial session configuration:
Continue sending audio during pauses. VAD commits the utterance after receiving the configured duration of silence:
Partial transcripts may arrive between these events.
Stream with VAD
Use the same module with turn_detection enabled. conversation.pcm should include the pauses between utterances. The receiver processes every completed result instead of stopping after the first.
During the recording, VAD commits on silence. When the file ends, the example sends one manual commit to flush any remaining speech, then waits for pending final results before closing. A live source can keep yielding audio for subsequent turns.
VAD events report audio_start_ms and audio_end_ms on the connection’s cumulative audio timeline; they do not reset after commit.
Automatic duration boundary
An utterance is also finalized when its input audio reaches the 36-second duration limit, including when VAD is enabled. The result has commit_reason: "max_duration". The connection stays open; continue receiving results for subsequent utterances.