is it possibel with the python agents SDK to get e...
# ask-ai
m
is it possibel with the python agents SDK to get events when someone is talking with VAD?
t
Thanks for reaching out, Jack. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — good question. Yes — with the Python Agents SDK you can receive VAD-related events when someone is speaking. Two ways to get that data: • Low-level VAD metrics: Load a VAD instance (for example,
silero.VAD.load()
), attach a handler to its
metrics_collected
event, and use that VAD in your
AgentSession
. The VAD emits
vad.VADEvent
objects with speech start/stop, idle time, inference timing, etc. Example:
Copy code
vad = silero.VAD.load()

def on_vad_event(event: vad.VADEvent):
    asyncio.create_task(handle_vad(event))

vad.on("metrics_collected", on_vad_event)

session = AgentSession(stt=..., llm=..., tts=..., vad=vad)
• Higher-level conversation state:
AgentSession
emits
user_state_changed
events (part of the turn-taking logic). You can listen for
ev.new_state == "speaking"
and
ev.new_state == "listening"
to know when a participant starts/stops speaking (this uses VAD internally). Example:
Copy code
@session.on("user_state_changed")
def on_user_state_changed(ev: UserStateChangedEvent):
    if ev.new_state == "speaking":
        print("User started speaking")
    elif ev.new_state == "listening":
        print("User stopped speaking")
Which approach do you want to use — raw VAD metrics or the higher-level user state events? If you share a short snippet of how you initialize your agent/session, I can show the exact code to wire it into your setup. Sources: VAD Metrics | LiveKit docs | Turns overview | LiveKit docs