Can i have conversation_item_added be triggered wh...
# ask-ai
a
Can i have conversation_item_added be triggered when the text finished generating (not when the tts finished speaking the text?)? if not; how else can i know specifically when the text finished generating and what's the text that was generated
t
Thanks for reaching out, Ali. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help clarify this for you! The
conversation_item_added
event usually fires after both text generation and TTS processing are done. But if you're looking to detect when text generation finishes on its own, without waiting for TTS playback, here are a few friendly tips you can try: • Keep an Eye on SpeechHandle Generation: You can use the
SpeechHandle
class to know exactly when text generation wraps up. For instance, hooking into the
_mark_generation_done()
method is a great way to catch that moment. • Watch Real-time Text Channels: Monitoring text channels like
text_ch
lets you see incremental updates as they happen. Once generation is complete, a completion signal will be sent your way. • Use Transcription Nodes: These are super handy for gathering generated text in real time, so you get access to the text as it’s created. When you want to grab the generated text, you can pull it from the
conversation_item_added
event payload, or try enabling
use_tts_aligned_transcript
in your session config to get TTS-aligned transcription forwarding. If you’d like me to walk you through any of these steps or if you have more questions, just let me know—I’m here to help! Sources: livekit-agents/livekit/agents/tts/stream_pacer.py | How to capture real-time agent transcriptions during conversations | Events and error handling | LiveKit Docs | Text and transcriptions | LiveKit Docs | How to detect when an agent has finished speaking
a
does transcription node give you the specific text generated by the agent (even if it's not spoken yet)?
t
By default, the transcription node provides text synchronized with audio playback, which means it shows the text as it’s being spoken. But if you'd like, you can change it to deliver the agent’s generated text right away, even before it’s spoken, by turning off synchronization. To do this, just set
sync_transcription=False
in
RoomOutputOptions
. If you’d like a hand with setting this up or customizing the transcription node further, please don’t hesitate to reach out—I’m here to help! Sources: Text and transcriptions | LiveKit Docs | livekit-agents/livekit/agents/voice/transcription/synchronizer.py | Pipeline nodes and hooks | LiveKit Docs
a
1. Transcription node; if i put sync_transcription=False; will it tell me when the text finished generating (even if not spoken yet) 2. For text_ch; how does it give the competion signal? does it also give the text generated?
t
1. Setting
sync_transcription=False
in the transcription node doesn’t directly tell us when text generation is finished. What it does is make sure transcriptions are sent right away as they become available, without waiting to sync up with the audio playback. The actual completion of text generation is tracked internally, using methods like
_mark_current_generation_done()
or flags such as
turn_complete
. 2. The
text_ch
(text channel) helps by signaling completion through closing the channel once text generation is done. Sometimes, an empty string is sent just before the channel closes. Plus,
text_ch
gives you the generated text bit by bit as it’s created, so you can access partial results during the process. If you’d like me to walk you through this further or help with the implementation, just let me know—I’m here to help! Sources: Text and transcriptions | LiveKit Docs | livekit-plugins/livekit-plugins-ultravox/livekit/plugins/ultravox/realtime/... | How to detect when an agent has finished speaking
a
but text_ch is only useful for realtime api model right? can i use it with a model like gpt-4.1; tts 11 labs?
t
Thanks for reaching out! Could you please share a bit more about how you're using GPT-4.1 and Eleven Labs? For instance, are they part of a custom setup or integrated through a specific API? Understanding this will really help me guide you on whether
text_ch
would work well in your situation. I'm here to help!
a
well just setting up a regular livekit agent but choosing gpt 4.1 as the llm!
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!