WebRTC transport implementation using LiveKit for real-time audio communication
LiveKitTransport
provides real-time audio communication capabilities using LiveKit’s open-source WebRTC platform. It supports bidirectional audio streaming, data messaging, participant management, and room event handling for conversational AI applications with the flexibility of self-hosted or cloud infrastructure.
UserAudioRawFrame
- Audio data from room participantsLiveKitTransportMessageUrgentFrame
- Data messages from participantsOutputAudioRawFrame
- Audio data to room participantsLiveKitTransportMessageFrame
- Data messages to participantsLiveKitTransportMessageUrgentFrame
- Urgent messages to participantsLiveKitTransport
provides methods for room and participant management:
get_participants()
- Get list of participant IDs in the roomsend_message()
- Send messages to participantssend_message_urgent()
- Send urgent messages to participantssend_audio()
- Send audio frames to the roomget_participant_metadata()
- Get metadata for specific participantsset_metadata()
- Set metadata for the local participantmute_participant()
- Mute a participant’s audio tracksunmute_participant()
- Unmute a participant’s audio tracksLiveKitTransport
API
reference.LiveKitTransport
provides event callbacks for room and participant management. Register callbacks using the @transport.event_handler()
decorator:
on_connected
- Connected to the LiveKit roomon_disconnected
- Disconnected from the LiveKit roomon_first_participant_joined
- First participant joins (useful for starting conversations)on_participant_connected
- Any participant joins the roomon_participant_disconnected
- Participant leaves the roomon_participant_left
- Participant left (alias for compatibility)on_audio_track_subscribed
- Audio track from participant is availableon_audio_track_unsubscribed
- Audio track is no longer availableon_data_received
- Data messages received from participantsLiveKitTransport
API
reference.