ambitious-psychiatrist-32073
08/03/2025, 2:55 AMtall-airline-16756
08/03/2025, 2:55 AMtall-airline-16756
08/03/2025, 2:55 AMambitious-psychiatrist-32073
08/03/2025, 2:56 AMtall-airline-16756
08/03/2025, 2:56 AM// Set audio input device
await room.setAudioInputDevice(device);
// Set audio output device
await room.setAudioOutputDevice(device);
// Set video input device
await room.setVideoInputDevice(device);
2. Using the LiveKit Agents:
# Create a custom RoomIO instance
room_io = RoomIO(
agent_session=agent_session,
room=room,
participant=selected_participant,
input_options=input_options,
output_options=output_options
)
# Set devices through the RoomIO instance
room_io.audio_input.set_participant(participant_identity)
room_io.video_input.set_participant(participant_identity)
3. Using Device Management APIs:
// List available devices
const devices = await Room.getLocalDevices('videoinput');
// Switch to a specific device
await room.switchActiveDevice('videoinput', deviceId);
4. Using MediaDeviceContext (Flutter Components):
// Select audio input device
mediaDeviceContext.selectAudioInput(device);
// Select audio output device
mediaDeviceContext.selectAudioOutput(device);
// Select video input device
mediaDeviceContext.selectVideoInput(device);
Just a quick heads-up: make sure to list out your devices before switching, give the right permissions, and keep in mind any platform quirks. If you hit any bumps or want to chat more about it, I’m here to help!
Sources: lib/src/hardware/hardware.dart | Building voice agents | LiveKit Docs | examples/demo/demo.ts | lib/src/context/media_device_context.dartambitious-psychiatrist-32073
08/03/2025, 2:57 AMtall-airline-16756
08/03/2025, 2:58 AM# Turn audio input on
session.input.set_audio_enabled(True)
# Turn audio input off
session.input.set_audio_enabled(False)
2. Set Up Initial Input/Output Settings:
session = AgentSession(
room_input_options=RoomInputOptions(audio_enabled=False),
room_output_options=RoomOutputOptions(audio_enabled=False)
)
These steps help you control your audio input and output settings whether you’re just starting your session or adjusting things on the fly. If you have any questions or want me to walk you through anything else, just let me know—I’m here to help!
Sources: examples/other/text_only.pyambitious-psychiatrist-32073
08/03/2025, 11:52 PMtall-airline-16756
08/03/2025, 11:52 PM# List available devices
const devices = await Room.getLocalDevices('audioinput'); // For microphones
const devices = await Room.getLocalDevices('audiooutput'); // For speakers
2. Choose Your Favorite Devices:
Once you’ve got the device IDs, just switch to the ones you want like this:
# Switch to a specific device
await room.switchActiveDevice('audioinput', micDeviceId); // For microphone
await room.switchActiveDevice('audiooutput', speakerDeviceId); // For speaker
Just swap out micDeviceId and speakerDeviceId with the IDs of the microphone and speaker you want to use.
If you have any questions or want a hand with this, just let me know—I’m here to help!ambitious-psychiatrist-32073
08/03/2025, 11:55 PMasync def entrypoint(ctx: agents.JobContext) -> None:
"""Main entrypoint for the voice agent configured for console operation."""
try:
print(":robot_face: Starting voice agent from console...")
print(f":link: Room name: {ctx.room.name}")
print(f":id: Room ID: {ctx.room.sid}")tall-airline-16756
08/03/2025, 11:56 PM