I want to process my llm output before passing it ...
# ask-ai
c
I want to process my llm output before passing it to the tts.
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.
I'm glad you're exploring ways to process LLM output before passing it to TTS! Here are a few friendly options you can try: • Using `before_tts_cb`: This handy callback in the
VoicePipelineAgent
lets you tweak the text just before it goes to the TTS engine. For instance, you can clean up or enrich the output by replacing or removing certain tags or phrases to make it sound just right. • Overriding `llm_node`: If you want more detailed control, you can subclass the
Agent
and override the
llm_node
method. This way, you can manipulate the raw LLM output stream before it reaches the TTS stage. • Combining
llm_node
and `tts_node`:
For those working with structured outputs, defining a schema to separate TTS control directives from spoken content allows you to apply voice instructions dynamically and seamlessly. All these methods work smoothly with LiveKit’s TTS pipeline, so your changes will be reflected throughout the audio generation process. If you'd like, I’d be happy to share some detailed examples or help you implement any of these approaches—just let me know! Sources: Docs::Agents | Pipeline nodes and hooks | LiveKit Docs | chain-of-thought-tts/agent.py | pipeline-llm/replacing_llm_output.py | Modifying LLM output before TTS | LiveKit Docs