broad-boots-9735
03/04/2026, 1:03 PMtall-airline-16756
03/04/2026, 1:04 PMtall-airline-16756
03/04/2026, 1:04 PMlk.transcription text stream on the client. Below are the key pieces and example code to get you started.
Backend — listen for transcription events
• Subscribe to the user_input_transcribed event on the AgentSession.
• The event payload includes:
◦ transcript (the text)
◦ is_final (boolean: false for interim updates, true when complete)
• Handle interim updates differently from final results if you need partial display vs. storage.
Python example:
@session.on("user_input_transcribed")
def on_transcript(transcript):
if transcript.is_final:
print(f"Final transcript: {transcript.transcript}")
else:
print(f"Interim transcript: {transcript.transcript}")
Frontend — receive text stream messages
• Agent text responses and transcriptions are sent over a TextStream topic named lk.transcription.
• Register a TextStreamHandler for that topic and read messages. Use the lk.transcribed_track_id attribute to tell user transcriptions apart from agent responses.
JavaScript example:
room.registerTextStreamHandler('lk.transcription', async (reader, participantInfo) => {
const message = await reader.readAll();
if (reader.info.attributes['lk.transcribed_track_id']) {
console.log(`User transcription: ${message}`);
} else {
console.log(`Agent response: ${message}`);
}
});
Quick notes and next steps
• Interim transcripts arrive while the speaker is still talking; final transcripts arrive when speech ends.
• If you want a full working example, check the Pi Zero Transcriber recipe which demonstrates logging real‑time final transcriptions to a file.
• If you’d like, tell me:
◦ Which language/runtime you’re using on the backend (Python, Node, etc.)
◦ Whether you need interim transcripts shown in a UI or only final transcripts saved
◦ If you plan to stream agent text-only responses or also want audio forwarded to an external STT provider
I can then provide a tailored code sample or an integration checklist for your stack.
Sources: Pi Zero Transcriber | LiveKit Documentation | How to build an agent with speech-to-text input and text-only output | Live... | Text and transcriptions | LiveKit Documentation