fancy-painting-20947
10/15/2025, 1:11 PMtall-airline-16756
10/15/2025, 1:11 PMtall-airline-16756
10/15/2025, 1:12 PMTrackMuted and TrackUnmuted events to know exactly when a track gets muted or unmuted.
room.on(RoomEvent.TrackMuted, (publication, participant) => {
if (participant === room.localParticipant) {
if (publication.source === Track.Source.Microphone) {
triggerMicrophoneWarning();
} else if (publication.source === Track.Source.Camera) {
triggerCameraWarning();
}
}
});
room.on(RoomEvent.TrackUnmuted, (publication, participant) => {
if (participant === room.localParticipant) {
clearWarnings();
}
});
Checking Mute Status:
• You can also check the current mute status anytime by using the isMuted property on track publications.
const micPub = room.localParticipant.getTrackPublication(Track.Source.Microphone);
const micEnabled = micPub && micPub.isSubscribed && !micPub.isMuted;
if (!micEnabled) {
triggerMicrophoneWarning();
}
These approaches should help you gently notify users when their microphone or video is off. If you have any questions or need a hand with implementation, just let me know—I’m here to support you!
Sources: src/room/events.ts | complex-agents/turn-taking/turn-taking-frontend/app/page.tsx | Samples~/JSExample/JSPackage~/src/index.ts | video-encode-decode-test/src/main/java/io/livekit/android/videoencodedecode... | README.mdfancy-painting-20947
10/15/2025, 1:15 PMtall-airline-16756
10/15/2025, 1:15 PMsession.say() not working. Let's walk through some common reasons this might happen, so we can get it sorted out together:
1. Session State: It’s important to make sure your session is active when you call session.say(). If the session isn’t running or is closing, this method won’t work as expected.
2. Missing TTS Plugin: Double-check that your agent has a Text-to-Speech (TTS) plugin configured. Without this, session.say() won’t function properly.
3. Event Timing: Sometimes, if the event triggering session.say() happens after the session has ended or is outside the right scope, the method can fail. Make sure the event fires while the session is still active.
4. Background Tasks: Try to avoid calling session.say() from asynchronous tasks that might continue after the session lifecycle ends.
To help you debug, you might want to:
• Keep an eye on the session state using the agent_state_changed event to confirm it’s in an active state like “listening” or “thinking.”
• Check if the speech_created event fires when you call session.say().
If you’d like, please feel free to share more details about your setup or any specific errors you’re seeing—I’m here to help you get this working smoothly!
Sources: pipeline-tts/tts_node.py | Events and error handling | LiveKit Docs | agents/src/voice/agent_activity.ts | livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/experimental/realti... | Agent speech and audio | LiveKit Docsfancy-painting-20947
10/15/2025, 1:19 PMtall-airline-16756
10/15/2025, 1:19 PMrtc.Room object. A great approach is to handle this within your agent class or a dedicated manager class like RoomIO. This helps keep everything nicely organized and ensures your room-level events are managed properly.
For instance, in your agent class, it might look like this:
class MyAgent:
def __init__(self, ctx: agents.JobContext):
self._ctx = ctx
async def connect(self):
await self._ctx.connect()
self._ctx.room.on("participant_connected", self._on_participant_connected)
self._ctx.room.on("participant_disconnected", self._on_participant_disconnected)
Or, if you prefer using a manager class like RoomIO, you could do it this way:
class RoomIO:
def __init__(self, agent_session: AgentSession, room: rtc.Room):
self._room = room
async def start(self):
self._room.on("participant_connected", self._on_participant_connected)
self._room.on("connection_state_changed", self._on_connection_state_changed)
Just a quick note: it's best to avoid registering room events inside the session class, since the session is really meant for session-specific events like agent_state_changed. If any of this feels unclear or if you'd like me to walk you through it further, please don't hesitate to ask—I’m here to help!
Sources: agent/game_host.py | livekit-agents/livekit/agents/voice/room_io/room_io.py | agent.py | agents/src/voice/room_io/room_io.ts