chilly-nest-87883
09/01/2025, 6:07 PMtall-airline-16756
09/01/2025, 6:07 PMtall-airline-16756
09/01/2025, 6:08 PMaudio_enabled from False to True anytime after you’ve started your AgentSession with session.start(). All you need to do is use session.input.set_audio_enabled(True) and session.output.set_audio_enabled(True) to turn the audio input and output on or off while your session is running.
Here’s a quick example: say you start the session with audio turned off:
session.input.set_audio_enabled(False)
session.output.set_audio_enabled(False)
await session.start(...)
Later on, if you want to enable audio, just do this:
session.input.set_audio_enabled(True)
session.output.set_audio_enabled(True)
This way, you don’t have to start with audio_enabled=True if you want to keep things text-only at first, and you can smoothly switch back and forth between text and voice whenever you like.
Sources: Text and transcriptions | LiveKit Docs | livekit-agents/livekit/agents/voice/io.py