Guides / Driving the avatar
Driving the avatar
There are three ways to make the avatar speak, plus barge-in to stop it.
Through the conversational model
send_message sends user text through the server's model. The model's reply is
synthesized and spoken by the avatar, and streams back to you as events.
await session.send_message("What's the weather like on Mars?")Optionally override the avatar for this turn:
await session.send_message("Say that again, but excited!", avatar="presenter-male-1080")The reply arrives as MESSAGE_STREAM_EVENT_RECEIVED chunks
followed by a final MESSAGE_RECEIVED, and is added to the conversation history.
Straight to speech
talk bypasses the model and speaks your exact text via TTS. It does not affect
conversation history.
await session.talk("This line is spoken immediately.")
await session.talk("With a little attitude.", tone="confident")talk() and talk streams require the server's control gateway. On a
server without it, they raise SessionError — use
send_message() instead, or upgrade the server. Check
session.has_control_channel.
Incrementally with a talk stream
When text arrives a bit at a time (e.g. tokens from your own model), stream it so the avatar starts speaking before the sentence is complete.
async with session.create_talk_stream() as talk:
await talk.send("Streaming ")
await talk.send("this ")
await talk.send("out loud.", end_of_speech=True)The first chunk is automatically flagged as the start of speech; mark the last one
with end_of_speech=True (or just exit the async with, which closes the
stream). See Talk streams for the full API.
Barge-in
Stop the avatar mid-utterance at any time:
await session.interrupt()This is the same barge-in the live voice pipeline uses — the avatar eases back to
its idle/listening pose. A TALK_STREAM_INTERRUPTED event
fires.
Choosing between them
| Method | Runs the model? | History? | Needs gateway? |
|---|---|---|---|
send_message | ✅ | ✅ | falls back to HTTP |
talk | ❌ | ❌ | ✅ |
create_talk_stream | ❌ | ❌ | ✅ |