This message was deleted.
# ask-ai
s
This message was deleted.
t
Thanks for reaching out, Mohammed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
AudioCaptureOptions in LiveKit are configuration objects used to control how audio is captured and processed when creating local audio tracks. They allow you to configure various aspects of audio processing, such as: • echoCancellation: Removes audio feedback • noiseSuppression: Reduces background noise • autoGainControl: Maintains consistent audio volume • highpassFilter, typingNoiseDetection, voiceIsolation, and deviceId: These and other options can be available depending on the platform (Swift/iOS, Flutter, JavaScript, etc.) AudioCaptureOptions are passed when creating local audio tracks and can often be set as defaults at the room level for consistency across your app. Each SDK/platform has its own specific implementation, but the core options remain consistent. Platform-specific features such as built-in voice processing or advanced noise suppression are also respected, depending on your environment. If you need examples for a particular SDK or details about a specific property, let me know which platform or use case you're interested in. Sources: Sources/LiveKit/Types/Options/CaptureOptions.swift | lib/src/options.dart | src/room/track/options.ts
b
how to use it ? and if we can use it in python then how can we?
t
How to Use AudioCaptureOptions? Hey there! I totally get how tricky audio settings can be. In LiveKit's client SDKs (like JavaScript, Swift, or Flutter),
AudioCaptureOptions
comes in handy when you're creating a local audio track. Let me walk you through a typical example:
Copy code
// 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.ts
b
how to use this or alternative approaches in python
t
Hey there! Let's talk about audio capture and processing in the LiveKit Python SDK – it's actually pretty cool and flexible. Here's how you can make your audio sound amazing: • AudioProcessingModule (APM): Think of this as your audio's best friend. It helps clean up your sound by removing echoes, reducing background noise, and even adjusting your volume. Check out this quick example:
Copy code
from 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.
Copy code
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.
Copy code
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.md
b
AudioProcessingModule how to use this module in python, to create rooms, where these settings are enabled
t
Hey there! Let me tell you about the super cool AudioProcessingModule in the LiveKit Python SDK. This nifty tool helps you clean up your audio streams by reducing echo, cutting out background noise, and making your sound crystal clear—it's like having a personal audio cleanup wizard! 🎙️ Here's how you can use it:
Copy code
from 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:
Copy code
# 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:
Copy code
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