purple-rainbow-1246
08/05/2025, 2:58 PMRoomEvent.ActiveSpeakersChanged and ParticipantEvent.IsSpeakingChanged give me a binary isSpeaking and I had to workaround it to set the UI state.purple-rainbow-1246
08/05/2025, 3:00 PMRoomEvent.ActiveSpeakersChanged is to check if the localParticipant is not speaking anything to put the agent in a thinking state. But the localParticipant isSpeaking fires a lot of false negatives, and that causes the state to change constantly.few-analyst-46
08/06/2025, 1:57 AMagent_state_changed and publish it, then frontend can subscribe the the attribute change
@session.on(Events.agent_state_changed)
def change_agent_attribute(event: AgentStateChangedEvent):
"""Update room metadata when agent state changes"""
old_state = event.old_state
new_state = event.new_state
task = asyncio.create_task(
ctx.room.local_participant.set_attributes(
{
'agent_state': new_state,
}
)
)
task.add_done_callback(
lambda t: main_logger.debug(
'set agent state from %s to %s',
old_state,
new_state,
)
)purple-rainbow-1246
08/06/2025, 1:57 AM