i am haivng issues with streaming latency between ...
# ask-ai
b
i am haivng issues with streaming latency between my llm and tts, i can see llm batching tokens, but it is presenting entire sentances to tts, is there a livekit setting to assist with this
t
Thanks for reaching out, Nick. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! To help with the streaming latency between your LLM and TTS, you can try using the SentenceStreamPacer in LiveKit. It’s designed to manage token batching and sentence-level processing, which can really cut down latency and make the speech sound smoother. Here are the main settings to keep in mind: • min_remaining_audio: This is the minimum remaining audio duration before sending the next batch (default is 5.0 seconds). • max_text_length: The max text length sent to TTS at once (default is 300 characters). You’ve got two ways to set this up: 1. Using the default pacing:
Copy code
tts=tts.StreamAdapter(
    tts=openai.TTS(),
    text_pacing=True,  # use the default pacer configuration
)
1. Or, if you want to customize it:
Copy code
tts=cartesia.TTS(
    text_pacing=tts.SentenceStreamPacer(
        min_remaining_audio=3.0,
        max_text_length=300,
    )
)
This method buffers sentences, keeps an eye on how much audio is left, and sends batches when the thresholds are met. It really helps make the TTS output smoother and more efficient. If you want a hand setting this up or have any questions, just let me know—I’m here to help! Sources: livekit-agents/livekit/agents/tts/stream_adapter.py | Live Conversations with AI using ChatGPT and WebRTC | Voice Assistants | livekit/livekit_composite | DeepWiki