fierce-jordan-44682
09/18/2025, 9:22 AMtall-airline-16756
09/18/2025, 9:22 AMtall-airline-16756
09/18/2025, 9:23 AMuser_state_changed event in LiveKit! This event is triggered whenever a participant's voice activity state changes, which is determined by the Voice Activity Detection (VAD) module analyzing their audio. It’s a great improvement because it combines the older user_started_speaking and user_stopped_speaking events into one, making things simpler and more flexible for you.
Here are the Event Properties to keep in mind:
• `old_state`: This shows the previous state of the user.
• `new_state`: This indicates the current state of the user.
• `created_at`: A timestamp in milliseconds, telling you exactly when the state change happened.
And the Possible States you might see:
• `speaking`: The user has just started speaking.
• `listening`: The user has stopped speaking.
• `away`: The user hasn’t responded for a set amount of time (by default, 15 seconds, but you can customize this).
To catch this event in your code, you can use the @session.on("user_state_changed") decorator. If you’d like, I’m here to provide more details or examples to guide you through it!
Sources: Events and error handling | LiveKit Docs | Agents v0.x migration guide - Node.js | LiveKit Docs | agents/src/voice/events.ts | livekit-agents/livekit/agents/voice/agent_session.py | Turn detection and interruptions | LiveKit Docs