can you tell more about live noise cancellation me...
# ask-ai
r
can you tell more about live noise cancellation methods ?
t
Thanks for reaching out, Av. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
LiveKit offers two main ways to help keep your audio clear by cutting down on background noise: • Default WebRTC Noise & Echo Cancellation: This is our basic noise suppression and echo cancellation, which is turned on by default and you can easily tweak it through the SDKs. • Enhanced AI Noise Cancellation: If you're using LiveKit Cloud, you get access to some powerful AI-driven tools powered by Krisp, like Noise Cancellation (NC), Background Voice Cancellation (BVC), and BVCTelephony. You can choose to run these either on the client side or server side, depending on what works best for you. If you want, I’m happy to walk you through how to set these up or answer any questions you have about using them! Sources: Knowledge Management System | livekit/livekit_composite | DeepWiki | Noise & echo cancellation | LiveKit Docs | AI voice agents | LiveKit Docs | AI noise cancellation | LiveKit Docs | Enhanced noise cancellation | LiveKit Docs
r
how to enable default "*Default WebRTC Noise & Echo Cancellation*"
t
Hey there! If you want to enable the default WebRTC-based noise and echo cancellation in LiveKit, you can set up the
AudioCaptureOptions
when you connect to a room or capture audio. Most SDKs have these settings turned on by default, but just in case you want to customize, here are some handy examples: • JavaScript SDK: The defaults are already set to
true
, but you can explicitly configure them like this:
Copy code
await room.connect(url, token, {
  audioCaptureDefaults: {
    echoCancellation: true,
    noiseSuppression: true,
    autoGainControl: true
  }
});
Android SDK: These are enabled by default, but if you want to tweak:
Copy code
val options = LocalAudioTrackOptions(
  echoCancellation = true,
  noiseSuppression = true
)
Flutter SDK: The defaults include
noiseSuppression: true
and
echoCancellation: true
. • Swift SDK: On real devices, you might need to turn on WebRTC-based processing explicitly since it defaults to Apple’s Voice-Processing I/O. • Python SDK: You can enable it explicitly when creating an `AudioProcessingModule`:
Copy code
apm = AudioProcessingModule(
  echo_cancellation=True,
  noise_suppression=True
)
If you have any questions or want help with a particular SDK or setup, just give me a shout—I’m here to help! Sources: src/room/defaults.ts | livekit-android-sdk/src/main/java/io/livekit/android/room/track/LocalAudioT... | Sources/LiveKit/Types/Options/AudioCaptureOptions.swift | livekit-rtc/livekit/rtc/apm.py | AI noise cancellation | LiveKit Docs
r
Enhanced AI Noise Cancellation: how to work this
t
Hey there! Just wanted to share how you can set up Enhanced AI Noise Cancellation in LiveKit, either right on the frontend (outbound) or on the server side (inbound), depending on what fits your needs best: 1. Frontend (Outbound) Implementation This lets you apply noise cancellation directly to the audio coming from the participant's device. You can use this on Web, Swift, Android, Flutter, and React Native. • For Web: First, install the noise filter package: `npm install @livekit/krisp-noise-filter`Then, apply the filter whenever a local microphone track is published:
Copy code
room.on(RoomEvent.LocalTrackPublished, async (trackPublication) => {
  if (trackPublication.source === Track.Source.Microphone && trackPublication.track instanceof LocalAudioTrack) {
    const { KrispNoiseFilter, isKrispNoiseFilterSupported } = await import('@livekit/krisp-noise-filter');
    if (!isKrispNoiseFilterSupported()) {
      console.error("Krisp noise filter not supported in this browser");
      return;
    }
    try {
      await trackPublication.track.setProcessor(KrispNoiseFilter());
    } catch (e) {
      console.warn("Could not enable noise filter");
    }
  }
});
React Components: If you’re using React, the
useKrispNoiseFilter
hook makes things super easy:
Copy code
import { useKrispNoiseFilter } from '@livekit/components-react/krisp';

const krisp = useKrispNoiseFilter();
return (
  <button onclick={() => krisp.setNoiseFilterEnabled(true)}>
    Enable Enhanced Noise Cancellation
  </button>
);
2. Server-Side (Inbound) Implementation This one applies noise cancellation on the server for incoming audio, which is great if you’re working on voice AI apps. It’s supported on Python and Node.js. • For Python: Just install the package: `pip install "livekit-plugins-noise-cancellation~=0.2"`Then enable noise cancellation when you start your agent session:
Copy code
from livekit.plugins import noise_cancellation

await session.start(
  room_input_options=room_io.RoomInputOptions(
    noise_cancellation=noise_cancellation.BVC(),  # or NC(), BVCTelephony()
  ),
)
If you want a hand with a specific platform or have any questions, just let me know—I’m here to help! Sources: packages/react/src/hooks/cloud/krisp/useKrispNoiseFilter.ts | AI noise cancellation | LiveKit Docs | Noise &amp; echo cancellation | LiveKit Docs | Enhanced noise cancellation | LiveKit Docs | components/room.tsx