can i distinguish when a video avatar ended talkin...
# ask-ai
h
can i distinguish when a video avatar ended talking and its "user's turn"?
t
Thanks for reaching out, Gabi. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
LiveKit uses turn detection to figure out when a video avatar stops talking and it’s your turn to speak. Usually, this happens through Voice Activity Detection (VAD), which listens for silence in your audio. If the silence lasts longer than a set time (like 0.5 seconds by default), the system assumes you’ve finished your turn. If you’re looking for something a bit more advanced, LiveKit also offers other turn detection options, such as: • Speech-to-Text (STT): This uses signals from transcription services to know when speech ends. • Custom Turn Detector: A smart transformer-based model that reads the flow of conversation to avoid cutting in during natural pauses. • Manual Control: Gives developers the power to set turn boundaries themselves. You can tweak settings like silence thresholds and pick the detection mode that works best for you. Just let me know if you want help setting it all up—I’m here for you! Sources: How does end-of-utterance detection work in conversations? | AI voice agents | LiveKit Docs | Improving voice AI's turn detection with transformers | Turn detection and interruptions | LiveKit Docs | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti...
h
you did not understand. when i say video avatar i mean the video avatar that speaks what the tts node gave. for example tavus avatar. can i distinguish in some way when it finishes its turn?
t
Thanks for clearing that up! Just to make sure I’m on the right track—does the video avatar (like Tavus) work together with LiveKit’s TTS system, or does it run on its own? Also, are you trying to find an event or signal that tells you when the avatar stops talking, or would you like some help setting that up?
h
i believe the avatar runs on its own and the audio output directed to it, for generation and streaming to the room via
Copy code
agent_session.output.audio = DataStreamAudioOutput(
            room=room,
            destination_identity=self._avatar_participant_identity,
            sample_rate=SAMPLE_RATE,
            wait_remote_track=rtc.TrackKind.KIND_VIDEO,
        )
i'm trying to find an event or signal that tells me when it stops/ends talking
t
To know exactly when your video avatar finishes speaking using
DataStreamAudioOutput
, you can simply listen for the
playback_finished
event from the audio output instance. This event fires as soon as the avatar confirms that the audio playback is done. Here’s a quick example to get you started:
Copy code
@session.output.audio.on("playback_finished")
def on_playback_finished(ev: PlaybackFinishedEvent) -> None:
    logger.info(
        "playback_finished",
        extra={
            "playback_position": ev.playback_position,
            "interrupted": ev.interrupted,
        },
    )
This event gives you: • playback_position: The exact time (in seconds) when playback wrapped up. • interrupted: A True/False flag showing if the playback got cut off early. With this, you can easily sync up your app’s next steps or keep the conversation flowing smoothly once the avatar is done talking. If you want me to walk you through anything else, just let me know—I’m here to help! Sources: livekit-agents/livekit/agents/voice/agent_session.py | Bringing AI avatars to voice agents | How to detect when an agent has finished speaking
h
is there another event or signal?
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!
h
I wish to disconnect a participant only when its turn finished. can you suggest a way?