dry-rainbow-66344
09/02/2025, 8:46 AMtall-airline-16756
09/02/2025, 8:46 AMtall-airline-16756
09/02/2025, 8:47 AMAgentSession pipeline in LiveKit, you’ve got a few great options to choose from:
1. Using Pre-Built TTS Plugins: LiveKit supports providers like Cartesia, ElevenLabs, PlayHT, Groq, and OpenAI-compatible endpoints. You can easily get started by initializing the AgentSession with a TTS instance from these plugins. For example, here’s how you’d do it with Cartesia:
from livekit.plugins import cartesia
session = AgentSession(tts=cartesia.TTS(model="sonic-english"))
1. Using OpenAI-Compatible Custom Endpoints: If your custom TTS service offers an OpenAI-style API, you can use the openai_plugin.TTS and just point it to your custom base_url like this:
from livekit.plugins import openai as openai_plugin
tts_instance = openai_plugin.TTS(
model="custom-model",
voice="custom-voice",
base_url="http://your-custom-tts-service:8000/v1"
)
1. Implementing a Fully Custom TTS Provider: If you want full control, you can override the tts_node method in your custom agent. This way, you can handle the text however you want before sending it off to your TTS engine.
from livekit.agents import Agent
class CustomTtsAgent(Agent):
async def tts_node(self, text, model_settings):
async for chunk in text:
yield f""
1. Standalone TTS Streaming: You can also use TTS on its own to stream audio directly into a room track.
If you want, I’m here to help you pick the best option or dive deeper into any of these methods. Just let me know!
Sources: Text-to-speech (TTS) integrations | LiveKit Docs | PlayHT integration guide | LiveKit Docs | Groq TTS integration guide | LiveKit Docs | ElevenLabs TTS integration guide | LiveKit Docs | examples/voice_agents/realtime_with_tts.pydry-rainbow-66344
09/02/2025, 8:47 AMtall-airline-16756
09/02/2025, 8:48 AMdry-rainbow-66344
09/02/2025, 8:49 AM