Is it possible to disable transcription syncing mi...
# ask-ai
n
Is it possible to disable transcription syncing mid-session? I want the user to be able to switch from an audio-only mode to a text-only mode. If they do so while the agent is speaking, the audio output should be stopped immediately but the text output should continue (ideally it should be fully flushed immediately if the full LLM stream is available).
t
Thanks for reaching out, Cecchi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking whether you can disable transcription syncing mid-session so a user can switch from audio-only to text-only and immediately stop audio while continuing (and ideally flushing) text. Short answer and steps: • You can stop audio immediately and continue text output mid-session. a. Call
session.interrupt()
to immediately stop the agent’s current speech/playback. b. Call
session.output.set_audio_enabled(false)
to disable publishing agent audio to the room. • You cannot change
sync_transcription
mid-session. ◦
sync_transcription
must be set when the session starts. If it is true, transcription may wait for audio alignment and will not flush immediately when audio is stopped. • Recommended approach to get the behavior you want: a. Start the session with
sync_transcription=false
so text is decoupled from audio timing. b. When switching to text-only: • Call
session.interrupt()
• Call
session.output.set_audio_enabled(false)
• Text (LLM stream/transcriptions) will continue and be forwarded immediately to
lk.transcription
. If you want, tell me whether your session already has
sync_transcription
enabled or share how you're starting the session (session config snippet), and I’ll give the exact code sequence you should use. Sources: Turn detection and interruptions | LiveKit Docs | Text and transcriptions | LiveKit docs
n
Setting
sync_transcription=false
works for the text-only mode, but creates confusing behavior in voice mode: if the user interrupts the agent mid-speech, the full response will have likely already been committed to the text stream. This means the chat history (and what the agent “thinks” has happened) and what the user has actually experienced are out of sync. The agent may reference things they “said” but that the user never heard. Furthermore if the user later switches to text mode they will see generated text they never heard. Is it possible to properly support interruptions with sync_transcription=false, but somehow retroactively modifying the transcripts? Or is there a different approach?
t
Thanks — this is a great concern and you’ve summarized the UX problem precisely. Short answer: you cannot retroactively edit/retract messages already published to
lk.transcription
. To avoid the mismatch while keeping low-latency text, you need to gate or control what gets published yourself. Two recommended approaches: 1) Gate final transcript publishing (recommended) • Keep
sync_transcription=false
for low-latency text generation. • Implement a transcription buffer in your agent (override the
transcription_node
) that collects LLM/transcription chunks but does NOT forward them to
lk.transcription
until playout is confirmed. • On voice → text-only switch or normal completion: ◦ If the speech finished or was not interrupted, flush the buffered text to
lk.transcription
. ◦ If interrupted (call
session.interrupt()
), truncate the buffer to the portion actually played (or discard it) and then publish the truncated/approved text. • You can await the
SpeechHandle
returned by
session.say()
/
session.generate_reply()
to know final vs interrupted state for each utterance. 2) Dual-stream / interim approach • Keep
sync_transcription=true
during voice mode to preserve alignment by default so transcripts reflect what was actually played. • Publish low-latency interim text to a separate topic (e.g.,
lk.interim_notes
) while generating speech so text-mode clients can show progressive updates without polluting the official transcript. • When playout completes, publish the final aligned transcript to
lk.transcription
. If interrupted, only the aligned/truncated final text goes to
lk.transcription
. Which to pick • Use option 1 if you want a single canonical transcript stream and full control over what appears there (best for consistent chat history). • Use option 2 if you want the safety of built-in sync during voice with the UX benefit of seeing fast interim text in a separate UI element. If you want, share how you produce/playback speech (code snippet showing
session.say()
or
session.generate_reply()
and how you currently publish transcription) and I’ll give a concrete sample for buffering/truncation logic or the dual-stream pattern. Sources: Text and transcriptions | LiveKit docs | Pipeline nodes and hooks | LiveKit docs | Agent speech and audio | LiveKit docs