Is there a way to integrate LiveKit with a physica...
# ask-ai
r
Is there a way to integrate LiveKit with a physical hardware microphone
t
Thanks for reaching out, Oliver. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're interested in integrating physical hardware microphones with LiveKit! Our SDKs make it quite straightforward by managing device access, permissions, and real-time audio processing for you. Here are some helpful options to get you started: • Rust SDK: You can easily list and select specific input devices, like USB microphones. For instance, to stream audio from a particular microphone, you can use this command:
Copy code
cargo run -- \
  --url "wss://your-project.livekit.cloud" \
  --api-key "your-api-key" \
  --api-secret "your-api-secret" \
  --input-device "USB Microphone"
• Python SDK: The
sounddevice
library helps capture audio from either the default or a specified microphone. You can also enable echo cancellation and start streaming like this:
Copy code
streamer = AudioStreamer(enable_aec=True)
streamer.start_audio_devices()
• Web and Mobile: LiveKit will prompt users for microphone permissions automatically in browsers. On mobile devices, just make sure microphone permissions are properly declared in your
Info.plist
or
AndroidManifest.xml
. • Embedded Systems: If you're working with devices like Raspberry Pi, you can capture and stream audio using USB or I2S microphones. If you have any questions or need help with a specific platform, please don’t hesitate to reach out—I’m here to help! Sources: examples/local_audio/README.md | stream_audio.py | docs/index.yaml | Camera & microphone | LiveKit Docs | Understanding "silence detected on local audio track" warning
r
Explain how the Rust and python sdk examples work exactly
t
Let me walk you through how the Rust and Python SDK examples for LiveKit microphone integration work—they’re designed to make your audio experience smooth and interactive! • Rust SDK Example: This example captures audio from your local microphone and streams it to a LiveKit room, while also playing back audio from other participants. You can choose your input/output devices, and enjoy real-time level metering along with helpful audio processing features like echo cancellation, noise suppression, and auto gain control (which is on by default). You’ll set it up using environment variables or CLI arguments where you provide details like the LiveKit server URL, API credentials, room name, participant identity, and audio device settings. You can easily list available audio devices, join specific rooms, or even run in capture-only mode by turning off playback. • Python SDK Example: Similarly, the Python example offers two-way audio streaming with real-time processing. It includes built-in acoustic echo cancellation (AEC), real-time dB level meters for both your microphone and remote participants, plus handy mute controls (just press "M" to toggle mute and "Q" to quit). It uses the
sounddevice
library to handle audio I/O and automatically detects your audio devices. Configuration is done through a
.env
file where you add your
LIVEKIT_URL
, API credentials, and room name. You run the script with
uv run stream_audio.py
. The terminal UI shows connection stats, audio levels, and participant info, and lets you set your participant name, disable AEC, or enable debug logging. One important tip: both examples work best with headphones to avoid audio feedback and ensure the best sound quality. If you have any questions or would like help setting these up, just let me know—I’m here to help! Sources: stream_audio.py | README.md