I am using livekit for a voice agent with elevenla...
# ask-ai
g
I am using livekit for a voice agent with elevenlabs as TTS, the issue i am facing is the cost. since the audio generate by the agent is mostly same as the call script is same for all the candidates, is there any way I can cache the tts and use that same without regenerating each time
t
Thanks for reaching out, Pavan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand you're looking to manage TTS audio more efficiently with LiveKit. While LiveKit doesn’t have built-in caching for TTS audio, you can definitely set up caching on your end to save time and resources when the same scripts are used repeatedly. Here’s a friendly way to get started: • Keep your generated audio files stored locally or in an object storage system you prefer. • Create a unique key based on the input text and your TTS settings to easily check if the audio already exists. • When the same script comes up again, serve the cached audio instead of generating it anew. If you’d like, I’m here to walk you through the details or help with any part of setting this up. Just let me know! Sources: examples/other/text-to-speech/cartesia_tts.py | plugins/rime/src/tts.ts | Text-to-speech (TTS) models | LiveKit Docs
g
Yes plz do that
t
Thanks for reaching out! Could you please share a bit more about where you'd like to implement the caching? For instance: • At the LiveKit agent level • Within a specific TTS plugin (like Cartesia or Rime) • Or perhaps in your own application layer Also, it would be really helpful to know your main goal—are you aiming to reduce latency, lower API costs, or maybe support offline playback? Understanding this will allow me to guide you better. Sources: livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/tts.py | Text-to-speech (TTS) models | LiveKit Docs