I am using livekit cloud and setting up the noise ...
# ask-ai
b
I am using livekit cloud and setting up the noise cancellation room_input_options=RoomInputOptions( noise_cancellation=noise_cancellation.BVC(), ), But still there are unwanted noise that will trigger the agent
t
Thanks for reaching out, Rahul. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you set up noise cancellation effectively in LiveKit Cloud, here are some friendly tips: • Try using the
RoomInputOptions
class with the Background Voice Cancellation (BVC) model—it works wonders for reducing noise, especially in busy, multi-speaker settings. • Make sure noise cancellation is applied only in the agent code (inbound processing) and not at the same time in the frontend (outbound processing), so they don’t interfere with each other. • Keep your SDK version and noise cancellation plugin updated to enjoy the best and latest improvements. • Give real-world audio a try with handy tools like the noise canceller tool to see how it performs. If you’re still noticing some unwanted noise, it might help to check that dual Krisp-based filtering isn’t enabled and that the BVC model is set up correctly in your agent code. Please feel free to reach out if you’d like me to walk you through any of these steps—I’m here to help! Sources: Enhanced noise cancellation | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs
b
Can you provide the code
t
I'd love to help you set up noise cancellation using the Background Voice Cancellation (BVC) model in both Python and Node.js! Here's a simple example to get you started: Python:
Copy code
from livekit.plugins import noise_cancellation

await session.start(
    room=ctx.room,
    agent=Assistant(),
    room_input_options=RoomInputOptions(
        noise_cancellation=noise_cancellation.BVC(),
    ),
)
Node.js:
Copy code
import { noiseCancellation } from "@livekit/noise-cancellation-node";

await session.start({
  room,
  agent,
  roomInputOptions: {
    noiseCancellation: noiseCancellation.BVC(),
  }
});
Just a quick reminder to make sure you have the right noise cancellation plugin installed for your language: • For Python:
livekit-plugins-noise-cancellation
• For Node.js:
@livekit/noise-cancellation-node
If anything feels unclear or if you'd like me to walk you through any part of this, please don't hesitate to ask. I'm here to help!
b
Already have set this up but still it catches up with the background noise
t
I’m sorry to hear you’re still having trouble with background noise even after setting up BVC. Let’s work through some troubleshooting steps together to get this sorted out: • Verify Configuration: Please double-check that BVC is correctly enabled in your agent code and that it’s not running alongside Krisp noise cancellation in the frontend. Since BVC works best with raw audio input, using it with pre-processed input might cause unexpected results. • Check Echo Cancellation: Make sure that
echoCancellation
is enabled in
AudioCaptureOptions
. This helps prevent the agent from picking up its own audio output. • Test with Noise Canceller Tool: You might find it helpful to try the noise canceller tool to test your audio samples. Comparing results with and without BVC can give us more insight. • Network and Connectivity: Sometimes, unstable network conditions can impact audio quality. Ensuring a strong and stable connection might reduce disruptions. • Model Selection: Please confirm you’re using the BVC model, which is the most advanced option for voice AI noise suppression. Other models like
NC
or
Krisp
might not perform as well. If you’re still facing issues after trying these steps, just let me know. I’m here to help, and we can look into other solutions or escalate this for a deeper investigation if needed. Sources: Enhanced noise cancellation | LiveKit Docs | agent.py | agent/main.py | README.md | krisp-minimal/README.md
b
Where to setup echoCancellation
t
I'd love to help you with setting up
echoCancellation
! Could you please let me know which SDK you're using (like Python, Node.js, Flutter, JS, Swift, or something else)? That way, I can guide you through the exact steps tailored just for you. Sources: Noise & echo cancellation | LiveKit Docs | SIP troubleshooting guide | LiveKit Docs | Enhanced noise cancellation | LiveKit Docs | lib/src/track/options.dart | src/room/track/options.ts
b
Python
t
Hi there! When working with Python, the
echoCancellation
setting is usually handled on the frontend or client-side, since it’s part of the WebRTC audio capture process. If you’re using LiveKit’s server-side agent, this setting isn’t something you can adjust directly in the agent code. To make sure echo cancellation is working well, please check that your frontend application—like your browser or client SDK—has
echoCancellation
enabled in its audio capture options. For example, in a WebRTC-based frontend, you can set it up like this:
Copy code
audioOptions = {
    "echoCancellation": True,
    "noiseSuppression": True,
    "autoGainControl": True
}
If you’re noticing echo issues on the agent side, it’s a good idea to double-check that the frontend is sending clean audio with echo cancellation turned on. Feel free to reach out if you’d like me to explain anything further or help you troubleshoot!
b
for frontend I am using livekit-components/react
t
Great question! In
livekit-components/react
, echo cancellation is actually enabled by default thanks to WebRTC's
AudioCaptureOptions
. So, in most cases, you won’t need to do anything extra unless you want to customize it specifically. If you’re setting up a
Room
manually, here’s a friendly reminder on how to make sure echo cancellation is turned on:
Copy code
import { Room } from 'livekit-client';

const room = new Room({
  audioCaptureOptions: {
    echoCancellation: true,
    noiseSuppression: true,
    sampleRate: 48000,
    audioMode: 'stereo',
  },
});
Also, when using server-side noise cancellation like BVC, it’s important to keep echo cancellation enabled to avoid the agent picking up its own audio output. If you have any more questions or need a hand with this, just let me know—I’m here to help! Sources: components/room.tsx | Enhanced noise cancellation | LiveKit Docs | Noise & echo cancellation | LiveKit Docs | Sources/LiveKit/Types/Options/AudioCaptureOptions.swift | Operational Guidance & Best Practices | livekit/livekit_composite | DeepWik...
b
How to handle echo & noise cancellation for inbound or outbound calls via SIP. This doesn't require any frontend. since for telephony implementation, frontend sdk is not required. Currently using only livekit server sdk
t
Hi there! I’m here to help you with handling echo and noise cancellation for your inbound or outbound SIP calls using the LiveKit server SDK without a frontend. Let’s walk through it together: 1. Noise Cancellation (via Krisp) • For inbound calls, you can enable noise cancellation by setting
krisp_enabled: true
in your SIP trunk configuration like this:
Copy code
{
  "inbound_addresses": [
    "192.0.2.0/24"
  ],
  "inbound_numbers_regex": "\\+1-510-555-0100",
  "krisp_enabled": true
}
• For outbound calls, just include
krisp_enabled: true
in your
CreateSipParticipant
request:
Copy code
{
  "from": "+1234567890",
  "to": "+0987654321",
  "room_name": "my-room",
  "krisp_enabled": true
}
This way, Krisp will help clean up the audio coming from your SIP endpoint. 2. Echo and Basic Noise Suppression • Good news! LiveKit automatically applies WebRTC-based echo cancellation and noise suppression for all participants by default. • If you want more advanced control, you can use the
AudioProcessingModule
in your server-side agent code to process audio streams. Here’s how you can do it:
Copy code
from livekit.rtc import AudioProcessingModule, AudioFrame

apm = AudioProcessingModule(
    echo_cancellation=True,
    noise_suppression=True,
    auto_gain_control=True
)

# Process audio from microphone (near-end)
audio_frame = AudioFrame(...)
apm.process_stream(audio_frame)

# Process speaker output (far-end) for echo reference
speaker_frame = AudioFrame(...)
apm.process_reverse_stream(speaker_frame)

# Set estimated delay between streams
apm.set_stream_delay_ms(50)
3. A Couple of Helpful Notes • Be sure not to apply
krisp_enabled
twice — for example, both in the SIP config and the agent processing. • The
AudioProcessingModule
gives you full control over echo, noise, and gain adjustments if you need it. If anything feels unclear or you’d like a hand with the implementation, please don’t hesitate to ask. I’m here to support you every step of the way! Sources: livekit-agents/livekit/agents/voice/chat_cli.py | README.md | Enhanced noise cancellation | LiveKit docs | livekit-rtc/livekit/rtc/_proto/track_pb2.pyi | examples/local_audio/src/main.rs
b
How can I implement this - AudioProcessingModule in AgentSession or entrpoint
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!