OK, for agents/examples/voice_agents/toggle_io.py at main · livekit/agents · GitHub , when I connect to a room I see the following exception:
Exception: cannot access local participant before connecting
I will need to fix that in the sample, but the fix is to add:
await ctx.connect()
Immediately after await session.start(…)
After you apply that fix and connect to a room, it should work. You can test it as follows:
- Start the agent
uv run examples/voice_agents/toggle_io.py dev - Use the Agents Playground as a front end: https://agents-playground.livekit.io/
- Press
Connectin the Playground and allow the agent to connect to your toom - Under the
RPCoptions in the playground specify the method name astoggle_inputand then the Payload is eitheraudio_offoraudio_on- you should see the agent stops or starts responding to your speech. - The example is written with the OpenAI realtime LLM, but it should work with any LLM/STT/TTS - you’ll need to modify it to match your setup if you don’t have an OpenAI key