Here is my pipeline session = AgentSession( ...
# ask-ai
w
Here is my pipeline session = AgentSession( stt=openai.STT(model=“gpt-4o-transcribe”, language=“en” ), llm=openai.LLM(model=“gpt-4o-mini”), tts=openai.TTS(model=“gpt-4o-mini-tts”, voice=“nova”), vad=silero.VAD.load(), _turn_detection_=MultilingualModel(), ) I how do I change it to use openai.realtime. for tts
t
Thanks for reaching out, Ilya. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To use
openai.realtime
for TTS in your pipeline, you’ll want to set up the
RealtimeModel
to work in text-only mode and then connect it with a TTS plugin for voice synthesis. Here’s a simple way to adjust your setup: 1. Start by initializing the
RealtimeModel
with
modalities=["text"]
so it focuses on producing text responses. 2. Next, pick a TTS plugin like
openai.TTS
,
elevenlabs.TTS
, or
cartesia.TTS
to transform that text into speech. Here’s an example you can follow:
Copy code
session = AgentSession(
    stt=openai.STT(model="gpt-4o-transcribe", language="en"),
    llm=openai.realtime.RealtimeModel(modalities=["text"]),
    tts=elevenlabs.TTS(voice_id="your-voice-id"),
    vad=silero.VAD.load(),
    turn_detection=MultilingualModel(),
)
This way, your Realtime model focuses on generating text, and the TTS plugin takes care of turning that text into speech. If you have any questions or need a hand with this, please don’t hesitate to ask—I’m here to help! Sources: OpenAI Realtime API integration guide | LiveKit Docs | OpenAI Realtime API integration guide | LiveKit Docs | examples/voice_agents/realtime_with_tts.py | plugins/openai/src/tts.ts | Realtime model integrations | LiveKit Docs
w
Oh, so tts in openai realtime doesn’t have any impact on the voice quality?
t
I’m glad you asked about voice quality—it really depends on how you set up your pipeline: • When using `modalities=["text"]`: The Realtime model will give you text only, and the voice quality then depends completely on the TTS plugin you choose (like
openai.TTS
or
elevenlabs.TTS
). The plugin’s settings, such as the voice and model you pick, shape the tone and expressiveness. • When using `modalities=["text", "audio"]`: The Realtime model creates audio directly, and the voice quality is influenced by internal settings like
voice
,
temperature
, and
speed
. These help define how the speech sounds in terms of tone, rhythm, and delivery. If you’d like, I’m here to help you explore these options further and get everything just right for you! Sources: Realtime model integrations | LiveKit Docs | examples/voice_agents/structured_output.py | plugins/openai/src/tts.ts | OpenAI Realtime API integration guide | LiveKit Docs | agent/main.py
w
What’s the best model for more human sound voice with emotions and stuff
t
I'm happy to help you find the best model for generating human-like voices with emotional expressiveness, depending on the TTS provider you choose: • Cartesia: I recommend the
sonic-2-2025-03-07
model, which gives you direct control over emotions like anger, positivity, sadness, and curiosity, with adjustable intensity levels to suit your needs. • Hume AI: This one is great if you're looking for deep emotional understanding and expressive speech generation—perfect for applications that really need emotional depth. • ElevenLabs: The
eleven_turbo_v2_5
model provides high-quality, human-like voices, and you can fine-tune emotional qualities using settings like stability and style. • Rime: With the
arcana
model, you get natural tones, pacing, and emotions for beautifully expressive voice synthesis. • LMNT: For dynamic emotional speech, try models with higher
temperature
and
top_p
values. If you'd like, I’d be more than happy to guide you through setting up any of these options—just let me know! Sources: ElevenLabs integration guide | LiveKit Docs | livekit-plugins/livekit-plugins-cartesia/livekit/plugins/cartesia/tts.py | Hume TTS integration guide | LiveKit Docs