how to enable noise cancellation in agents?
# ask-ai
n
how to enable noise cancellation in agents?
t
Thanks for reaching out, Tareq. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To enable noise cancellation in LiveKit agents, follow these steps: Installation First, install the noise cancellation package:
Copy code
pip install "livekit-plugins-noise-cancellation~=0.2"
Usage in LiveKit Agents Include the filter in
RoomInputOptions
when starting your `AgentSession`:
Copy code
from livekit.plugins import noise_cancellation

# ...
await session.start(
    # ...,
    room_input_options=room_io.RoomInputOptions(
        noise_cancellation=noise_cancellation.BVC(),
    ),
)
# ...
Available Models There are three noise cancellation models available: • `noise_cancellation.NC()`: Standard enhanced noise cancellation • `noise_cancellation.BVC()`: Background voice cancellation (removes non-primary voices) • `noise_cancellation.BVCTelephony()`: Optimized for telephony applications Recommended Model For most 1:1 voice AI applications, LiveKit recommends using the
BVC
model as it removes extra background speakers in addition to background noise, providing the best experience for voice AI applications. Complete Example Here’s a complete example:
Copy code
from livekit.plugins import noise_cancellation

await session.start(
    agent=MyAgent(),
    room=ctx.room,
    room_input_options=RoomInputOptions(
        # Enable Krisp BVC noise cancellation
        noise_cancellation=noise_cancellation.BVC(),
    ),
    room_output_options=RoomOutputOptions(transcription_enabled=True),
)
Important Note When using server-side noise or background voice cancellation, client-side noise cancellation should be disabled. Noise cancellation models are trained on raw audio and may produce unexpected results if the input has already been processed on the client. Compatibility For LiveKit Agents v0.12, pass the
noise_cancellation
parameter to the
VoicePipelineAgent
or
MultimodalAgent
constructor instead. Sources: AI noise cancellation | LiveKit Docs | examples/voice_agents/restaurant_agent.py | Audio and video | LiveKit Docs | Enhanced noise cancellation | LiveKit Docs
m
@bored-eye-46869
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!