crooked-dawn-90821
10/07/2025, 3:31 PMtall-airline-16756
10/07/2025, 3:31 PMtall-airline-16756
10/07/2025, 3:31 PMtrackPublished event to know when an audio track is published:
room.on('trackPublished', (trackPublication, participant) => {
if (trackPublication.kind === 'audio') {
trackPublication.on('subscribed', (track) => {
console.log('Received audio track');
// This is where you can work with the audio track
});
}
});
If you’d also like to get the text version of the TTS output, you can enable synchronized transcription forwarding. Just use registerTextStreamHandler to listen for text streams on the lk.transcription topic:
room.getLocalParticipant().registerTextStreamHandler('lk.transcription', async (reader) => {
for await (const text of reader) {
console.log('Agent is speaking:', text);
// You can update your UI with captions or subtitles here
}
});
Please feel free to reach out if you’d like me to walk you through any part of this or if you have any other questions—I’m here to help!
Sources: agents/src/voice/agent.ts | Voice Assistant Applications | livekit/livekit_composite | DeepWiki | Text and transcriptions | LiveKit Docs