Hi everyone, I'm running into a performance issue ...
# ask-ai
c
Hi everyone, I'm running into a performance issue with my Python-based LiveKit voice agent and would appreciate any insights. Setup: • Framework:
livekit-agents
(Python) • Stack: Google STT, OpenAI LLM (
gpt-4o-mini
), and I've tried both OpenAI TTS and Google TTS. • Deployment: The agent is running on a GCP instance with 2GB of RAM. The Problem: The agent works perfectly for the first 4-5 minutes of a call. The conversation is responsive and near real-time. However, right around the 5-minute mark, the agent's performance begins to degrade significantly. Responses become very delayed, and eventually, the agent stops responding altogether. Key Log Observations: The logs show a clear pattern leading to the failure: 1. At the 5-minute mark, I see this log: DEBUG - flush audio emitter due to slow audio generation 2. Shortly after , the agent process is terminated by the worker: WARNING - process is unresponsive ERROR - process is unresponsive, killing process
t
Thanks for reaching out, Abdulwahid. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm sorry to hear you're experiencing performance issues with your LiveKit voice agent. Let's walk through what might be causing this together: • Slow TTS Audio Generation: The message "flush audio emitter due to slow audio generation" suggests that the audio synthesis isn't keeping up in real time. This could be due to heavy computational demands, delays from external TTS services, or some inefficiencies in how the audio stream is handled. • Unresponsive Process: The "process is unresponsive, killing process" log comes from a heartbeat check that watches if the agent is responding. If it doesn't reply in time, it gets terminated. This might happen because of CPU-heavy tasks, memory strain, or synchronous operations that block the event loop. Also, if memory usage goes beyond the set limits, that can cause the process to stop as well. To help improve things, I recommend looking into optimizing your TTS pipeline, making sure audio processing runs smoothly, and keeping an eye on system resources while the agent is running. If you need any help with these steps, feel free to reach out—I'm here to support you! Sources: livekit-agents/livekit/agents/ipc/supervised_proc.py
c
I thought livekit handles all right why do i need to put extra effor for optimizing the tts pipeline? all I have is stt_instance = google.STT() llm_instance = openai.LLM(model="gpt-4o-mini") tts_instance = openai.TTS(model="tts-1", voice=voice_config["voice"]) session = AgentSession( stt=stt_instance, llm=llm_instance, tts=tts_instance, )
t
Hi there! LiveKit takes care of many parts of the TTS pipeline for you, like handling interruptions, forwarding transcriptions, and doing incremental synthesis for non-streaming TTS engines. That said, there are times when a bit of manual tweaking or customization can really help, especially if you're working with particular TTS providers or more advanced setups. For instance, LiveKit has fallback options like sentence-level chunking for non-streaming TTS engines, but if you're aiming to improve latency or audio quality, some adjustments might be needed. You also have the flexibility to override the
tts_node
to create custom behaviors—this could be anything from different ways to chunk text, using custom TTS engines, or applying specialized audio processing. Regarding the performance issue you're experiencing, it could be related to how quickly the TTS engine responds or how the system handles audio processing. I'd be happy to walk you through some specific optimizations or settings that might help boost performance. Just let me know! Sources: Building voice agents | LiveKit Docs | ElevenLabs TTS plugin guide | LiveKit Docs | Pipeline nodes and hooks | LiveKit Docs | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/tts.py
c
That is not helpful at all!
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!