abundant-father-33863
08/22/2025, 10:05 AMtall-airline-16756
08/22/2025, 10:05 AMtall-airline-16756
08/22/2025, 10:06 AMbefore_tts_cb function, a simple way is to return empty content so no audio gets synthesized. Here’s a quick example to show you how:
async def _before_tts_cb(agent: VoicePipelineAgent, text: str | AsyncIterable[str]):
# Check if you want to stop TTS
if should_stop_tts():
if isinstance(text, str):
return "" # Just return an empty string
else:
# Return an empty async generator for streaming
async def empty_stream():
return
yield # This line never actually runs
return empty_stream()
# Otherwise, go ahead and process normally
return text
And if you’re working with LiveKit Agents 1.0 or newer, you might want to check out the `tts_node`—it gives you even more flexibility to customize your TTS pipeline. Feel free to reach out if you want a hand with that or have any specific scenarios where you want to stop TTS. I’m here to help!
Sources: chain-of-thought-tts/agent.py | VoicePipelineAgent | LiveKit Docs | Agents v0.x migration guide | LiveKit Docs