Skip to main content

Interrupt the avatar

When the user starts talking over the avatar, call clear(). It drops the audio that hasn’t played yet, stops the avatar mid-sentence, and resolves with how many milliseconds of the interrupted reply the user heard.
Call it wherever your app already handles barge-in, such as your voice activity detector’s speech started event.

Keep the transcript accurate

Your agent’s model generated the whole reply, but the user only heard part of it. Use heardMs to tell the model what was actually said. With OpenAI Realtime, truncate the assistant’s item to what was heard:

Speech events

on() returns a function that removes the listener:
Use these events to drive your UI (a speaking indicator, or a thinking state), or to know when the avatar has finished a goodbye before you close the session. See the full list of events in the LiveAvatar reference.