magnificent-dusk-62723
07/11/2025, 5:20 PMtall-airline-16756
07/11/2025, 5:21 PMtall-airline-16756
07/11/2025, 5:21 PMgoogle.beta.realtime.RealtimeModel
, use the generate_reply()
method with an instructions
parameter. Here is how you can do it:
session.generate_reply(
instructions="introduce yourself very briefly and ask about the user's day"
)
This method is asynchronous and returns a future event. It automatically manages the interaction turn and directly uses the RealtimeModel for speech (no separate TTS plugin needed). You can call this, for example, when a session starts or within an on_enter
method if you are using an agent class.
References:
Sources: examples/voice_agents/realtime_turn_detector.py | agent/main.py | Agent speech and audio | LiveKit Docsmagnificent-dusk-62723
07/11/2025, 5:22 PMtall-airline-16756
07/11/2025, 5:23 PMgenerate_reply()
with a friendly hint: You can tell the model to "Say exactly: '[Your message here]'". Here's a quick example:
session.generate_reply(
instructions="Say exactly: 'Hello, welcome to our service. How can I help you today?'"
)
Just a heads up though - realtime models can be a bit unpredictable. They might accidentally paraphrase or tweak the text a little because of how they naturally generate language .
• Second option (and my recommendation): Add a TTS plugin for guaranteed exact speech: Pop in a TTS plugin to your AgentSession
, and then use `session.say()`:
await session.say("Welcome! This is my exact intro message.")
This method is super reliable and makes sure your message comes out word-for-word .
Quick summary: Want total control? Go with session.say()
and a TTS plugin. If you're using generate_reply()
, just know the exact wording isn't a sure thing.
Sources: Realtime model integrations | LiveKit Docs | Agent speech | LiveKit Docs | packages/sip--make-a-call/src/agent.ts