Can I add a llm router in between LLM and TTS to d...
# ask-ai
c
Can I add a llm router in between LLM and TTS to decide if I want to use the TTS or not?
t
Thanks for reaching out, Subham. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! Just a heads-up—LiveKit doesn’t come with a built-in feature to add an LLM router between the LLM and TTS for deciding on the fly whether to use TTS. But no worries, you can totally make this happen by customizing the agent pipeline. Here’s a simple way to do it: 1. Create your own custom
Agent
class. 2. Override the
tts_node
method to add some logic that checks if TTS should run based on what the LLM outputs. 3. If you want, you can also tweak the
llm_node
method to help prepare or signal this decision. 4. Then, return either a modified or empty stream from
tts_node
to control the audio synthesis. This way, you can flexibly skip TTS when certain conditions are met. If you want, I’m here to help you walk through the implementation—just let me know! Sources: livekit-agents/livekit/agents/voice/generation.py | Pipeline nodes and hooks | LiveKit Docs
c
How to override the
tts_node
, any examples for the same?
t
Hey there! If you want to override the
tts_node
in LiveKit, the way to go is by subclassing the
Agent
class and creating your own
tts_node
method. This gives you the flexibility to tweak the text before it reaches the TTS engine, change up the audio output, or even plug in a custom TTS engine. Here are a few examples to get you started: Example 1: Simple Text Replacement Sources: pipeline-tts/tts_node.py | Agent speech and audio | LiveKit Docs | examples/voice_agents/structured_output.py
c
What is the best practice to get complete conversation transcript?
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!