| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This directory contains examples demonstrating various features of the LiveKit Python SDK.
Set the following environment variables:
export LIVEKIT_URL=ws://localhost:7880
export LIVEKIT_API_KEY=devkey
export LIVEKIT_API_SECRET=secret| Example | Description |
|---|---|
| basic_room.py | Room connection with PlatformAudio and synthetic audio modes |
| room_example.py | Basic room connection and event handling |
| api.py | Room management via LiveKit API |
| e2ee.py | End-to-end encryption demo |
| rpc.py | Remote Procedure Call between participants |
| multiple_connections.py | Sequential connections for sync frameworks |
| participant_attributes.py | Dynamic participant attributes |
| publish_wave.py | Publish sine wave audio |
| publish_hue.py | Publish color-cycling video |
| play_audio_stream.py | Play received audio with sounddevice |
| webhook.py | Webhook event handling |
| agent_dispatch.py | Manual agent dispatch |
| Directory | Description |
|---|---|
| face_landmark/ | Facial landmark detection using MediaPipe |
| video-stream/ | Video/audio sync with AVSynchronizer |
| data_tracks/ | Data channel examples |
| data-streams/ | Data streaming examples |
| local_audio/ | Local audio capture with dB metering |
The most comprehensive example, demonstrating room connection with audio capabilities. It showcases two audio capture modes that can be used independently or combined.
# List available audio devices
python basic_room.py --list-devices
# Connect with PlatformAudio (recommended)
python basic_room.py --platform-audio --room my-room
# Connect with specific devices
python basic_room.py --platform-audio --mic-id "device-guid" --speaker-id "device-guid"
# Publish a WAV file
python basic_room.py --file audio.wav --room my-room
# Mix microphone + WAV file (both modes together)
python basic_room.py --platform-audio --file background.wav --room my-roomUses WebRTC's Audio Device Module (ADM) for microphone capture. Recommended for most applications.
Features:
Limitations:
platform_audio = rtc.PlatformAudio()
source = platform_audio.create_audio_source(
rtc.PlatformAudioOptions(
echo_cancellation=True,
noise_suppression=True,
auto_gain_control=True,
)
)
track = rtc.LocalAudioTrack.create_audio_track("microphone", source)Manual control over audio frames via AudioSource.capture_frame(). Use this for custom audio processing or programmatic audio generation.
Features:
Limitations:
source = rtc.AudioSource(sample_rate=48000, num_channels=1)
track = rtc.LocalAudioTrack.create_audio_track("audio", source)
frame = rtc.AudioFrame(data=audio_bytes, sample_rate=48000, ...)
await source.capture_frame(frame)PlatformAudio and Synthetic modes can run simultaneously. The --file option demonstrates this by publishing a WAV file (synthetic) alongside microphone capture (PlatformAudio).
python basic_room.py --platform-audio --file music.wav --room my-roomThis creates two audio tracks:
Use cases: background music while speaking, sound effects, mixing pre-recorded audio with live input.
| Option | Description |
|---|---|
| --list-devices | List available audio devices and exit |
| --platform-audio | Use PlatformAudio for microphone (recommended) |
| --file WAV_PATH | Publish audio from WAV file (synthetic mode) |
| --room NAME | Room name (default: my-room) |
| --mic-id ID | Select microphone by device ID |
| --speaker-id ID | Select speaker by device ID |
| Use Case | Mode |
|---|---|
| Voice/video calls | PlatformAudio |
| Conferencing apps | PlatformAudio |
| Playing audio files | Synthetic |
| Text-to-speech | Synthetic |
| Custom audio processing | Synthetic |
| ML audio effects | Synthetic |
| Background music + voice | Both |
Examples for local audio capture with microphone and speaker management.
Full-duplex audio with microphone capture and speaker playout.
cd local_audio
python full_duplex.pyFeatures:
Publish microphone audio with dB level monitoring.
cd local_audio
python publish_mic.pyFeatures:
Basic room connection demonstrating event handling and participant tracking.
python room_example.pyRoom management using the LiveKit API (create rooms, list rooms).
python api.pyEnd-to-end encryption with a rotating 3D cube visualization.
python e2ee.pyRemote Procedure Call (RPC) between participants - greetings, math operations, timeout handling.
python rpc.pySequential room connections in a single thread. Useful for Django/Flask integration.
python multiple_connections.pySet, update, and delete participant attributes dynamically.
python participant_attributes.pyPublish a sine wave audio track at a specified frequency.
python publish_wave.pyPublish a color-cycling animated video track.
python publish_hue.pyPlay incoming audio from remote participants using sounddevice.
pip install sounddevice
python play_audio_stream.pyHandle LiveKit webhook events using aiohttp.
python webhook.pyManually dispatch agents to rooms (instead of automatic dispatch).
python agent_dispatch.py| Back | FazBrowse Home | New Git URL |