Skip to content

Label interim frames, commit finals in live transcription examples#22

Merged
arnavmehta7 merged 2 commits into
mainfrom
chore/erase-line-before-transcript-rewrite
May 26, 2026
Merged

Label interim frames, commit finals in live transcription examples#22
arnavmehta7 merged 2 commits into
mainfrom
chore/erase-line-before-transcript-rewrite

Conversation

@arnavmehta7
Copy link
Copy Markdown
Collaborator

@arnavmehta7 arnavmehta7 commented May 26, 2026

Summary

The realtime backend ships a cumulative transcript per utterance and resets it on each new utterance (is_final flips true on the finalizing frame). Printing every Results plainly floods a line per interim, and the older \r overwrite loses prior utterances after a pause.

This makes the examples is_final-aware:

  • interim frames print as [Interim] {text} lines;
  • the finalized utterance commits on its own line (\r\033[K{text}\n), so a new utterance after a pause no longer overwrites the previous one.

Also documents is_final / commit-on-final on the ResultsEvent docstring.

Test plan

  • python examples/live_transcription_microphone.py — speak, pause, speak again: each finished utterance lands on its own line; interims show as [Interim] …
  • python examples/live_transcription_file.py sample.wav — same, file-paced

🤖 Generated with Claude Code

@arnavmehta7 arnavmehta7 changed the title Erase line before each transcript rewrite in examples Print each transcript event on its own line in examples May 26, 2026
@arnavmehta7 arnavmehta7 changed the title Print each transcript event on its own line in examples Align live-transcription examples with the server contract May 26, 2026
@arnavmehta7 arnavmehta7 changed the title Align live-transcription examples with the server contract Live transcription: expose Finalize, align examples with the wired server contract May 26, 2026
Drop the '\r{transcript}' in-place rewrite trick. It worked for short
single-line transcripts but accumulated wrapped rows on screen when the
cumulative transcript exceeded terminal width, producing a 'stuck' /
repeated-text effect mid-session.

Plain newline-per-event has no overwrite logic to break — the terminal
scrolls naturally. Also drops the leading '\n' from error/closed prints
since the transcript is no longer in-place.
@arnavmehta7 arnavmehta7 force-pushed the chore/erase-line-before-transcript-rewrite branch from 2f7381b to c60cd7a Compare May 26, 2026 12:01
@arnavmehta7 arnavmehta7 changed the title Live transcription: expose Finalize, align examples with the wired server contract Print each transcript on a new line in examples May 26, 2026
Supersede the plain newline-per-event print with an is_final-aware
display: interim frames print as "[Interim] ..." lines and the finalized
utterance commits on its own line, so a new utterance after a pause no
longer overwrites the previous one. Document is_final / commit-on-final
on the ResultsEvent docstring.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@arnavmehta7 arnavmehta7 changed the title Print each transcript on a new line in examples Label interim frames, commit finals in live transcription examples May 26, 2026
@arnavmehta7 arnavmehta7 merged commit a11cced into main May 26, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant