steep-balloon-41261
07/11/2025, 1:55 PMtall-airline-16756
07/11/2025, 1:55 PMtall-airline-16756
07/11/2025, 1:56 PMbig-controller-60015
07/11/2025, 1:58 PMtall-airline-16756
07/11/2025, 1:59 PMAudioCaptureOptions
comes in handy when you're creating a local audio track. Let me walk you through a typical example:
// JavaScript example
const audioOptions = {
echoCancellation: true,
noiseSuppression: true,
autoGainControl: true,
};
const localTracks = await createLocalTracks({
audio: audioOptions, // Pass options here
video: true
});
Each SDK has its own little quirks with syntax, but the core idea is just passing the audio options you want when creating your local microphone track.
Can You Use AudioCaptureOptions in Python?
I hear you wondering about Python support. Unfortunately, the Python LiveKit SDK doesn't directly support AudioCaptureOptions
like the browser and mobile SDKs do. It offers some lower-level audio processing options, but they're more focused on server-side work rather than the client-side device controls you might be looking for.
If you need those precise audio capture controls, I'd recommend using one of the main client SDKs like JavaScript, Swift, or Flutter. The Python SDK has some audio processing modules, but they'll work a bit differently.
Want to chat more about your specific use case? I'm all ears and happy to help you find the best solution!
Sources: Sources/LiveKit/Track/Local/LocalAudioTrack.swift | lib/src/track/local/audio.dart | livekit-rtc/livekit/rtc/_proto/audio_frame_pb2.pyi | src/room/track/options.tsbig-controller-60015
07/11/2025, 2:00 PMtall-airline-16756
07/11/2025, 2:01 PMfrom livekit.rtc import AudioProcessingModule
apm = AudioProcessingModule(
echo_cancellation=True,
noise_suppression=True,
high_pass_filter=True,
auto_gain_control=True,
)
# Process audio frames (each frame must be 10ms)
apm.process_stream(audio_frame)
• AudioSourceOptions: These are like fine-tuning knobs for your audio source, helping you control echo, noise, and volume right from the start.
• Noise Cancellation Plugins: Want to take your audio game to the next level? Install livekit-plugins-noise-cancellation
for some seriously smart noise suppression.
pip install "livekit-plugins-noise-cancellation~=0.2"
from livekit.plugins import noise_cancellation
stream = rtc.AudioStream.from_track(
track=track,
noise_cancellation=noise_cancellation.BVC(),
)
• Device Selection: With libraries like sounddevice
, you can easily pick and choose your favorite audio devices.
import sounddevice as sd
input_device, output_device = sd.default.device
# Set input_device to your preferred device index
Here's the cool part – the Python SDK gives you way more hands-on control compared to other client SDKs. It's all about real-time, server-side processing. Pro tip: The Background Voice Cancellation (BVC) model is a game-changer for voice AI!
Need more details? Just let me know what you're working on, and I'll help you nail down the perfect audio setup!
Sources: livekit-rtc/livekit/rtc/audio_stream.py | Noise & echo cancellation | LiveKit Docs | README.mdbig-controller-60015
07/11/2025, 2:08 PMtall-airline-16756
07/11/2025, 2:09 PMfrom livekit.rtc import AudioProcessingModule
apm = AudioProcessingModule(
echo_cancellation=True,
noise_suppression=True,
high_pass_filter=True,
auto_gain_control=True
)
Processing audio is a breeze—just make sure your audio frames are 10ms each:
# process reverse stream (remote/far-end audio, for echo cancellation)
apm.process_reverse_stream(render_frame)
# process main stream (captured/microphone audio)
apm.process_stream(capture_frame)
Pro tip: You can even adjust stream delays using apm.set_stream_delay_ms(delay_ms)
to make your echo cancellation even more awesome!
For agents or bots, it's super simple—just set up your audio processing before sending it to a room. In LiveKit Agents, you'll do something like:
apm = AudioProcessingModule(...)
room_session = ...
# Capture/process your audio, then publish to room as usual
Want to take it up a notch? Check out noise cancellation plugins via livekit.plugins.noise_cancellation
with RoomInputOptions
when joining a room. It's like magic for your audio! ✨
Need a detailed walkthrough for a specific scenario? Just ask, and I'll be happy to help you out!
Sources: livekit-rtc/livekit/rtc/_proto/audio_frame_pb2.pyi | livekit-agents/livekit/agents/voice/chat_cli.py | stream_audio.py | Audio and video | LiveKit Docs