<@U07FRRZH2GN> How can we handle background noise,...
# ask-ai
f
@icy-policeman-64898 How can we handle background noise, when in public places
t
Thanks for reaching out, Abhishek. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about handling background noise when participants are in public places. Short answer: Use LiveKit’s background voice cancellation (BVC) and choose the telephony-optimized BVC for SIP/phone participants. These models remove non-primary speakers and most environmental noise while keeping the primary voice clear. What to use and when • For WebRTC/mobile/web participants: use Background Voice Cancellation (
BVC()
). • For SIP/telephony participants (narrow-band 8 kHz audio): use Telephony Background Voice Cancellation (
BVCTelephony()
). Important configuration tips • Don’t combine noise-cancellation models on the same audio path. If you enable agent-side BVC or BVCTelephony(), disable
krisp_enabled
on SIP trunks/frontends to avoid double-processing, which can worsen audio and increase latency. • Choose the telephony model only for narrow-band phone audio; it’s tuned for 8 kHz sampling rates and performs better than wideband models in that scenario. Implementation approach (conceptual) 1. Detect participant type (WebRTC vs SIP/telephony). 2. Select the appropriate filter: ◦ WebRTC ->
BVC()
◦ SIP ->
BVCTelephony()
1. Apply the filter to the participant’s input/audio pipeline before sending to agents or STT. Performance & cost notes • Noise cancellation runs locally and adds minimal latency (typically <10 ms). • Cleaner audio reduces STT errors and can lower transcription costs because fewer irrelevant words get transcribed. Testing recommendation • Test in representative public environments (cafés, transit, busy streets) and on target devices (phones, laptops) to verify the chosen model and any CPU impact. • If you see artifacts or loss of wanted audio, try toggling models or adjusting microphone placement (closer to speaker, using external mic) as a complement. If you’d like, I can: • Share a short example snippet for the language/platform you’re using (Node.js, Python, or client-side JS). • Help you decide which fields in your current setup to change (for example, where to disable
krisp_enabled
) — if you tell me what platform and participant types you have. Sources: Choosing the right noise cancellation for your agent | LiveKit
f
Share a short example snippet for python
t
Thanks — I’m responding to your request for a short Python example that shows how to select and apply background voice cancellation for WebRTC vs SIP participants. Below is a concise snippet that: • Detects participant kind • Chooses
BVC()
for normal WebRTC participants and
BVCTelephony()
for SIP participants • Starts a session with the selected noise-cancellation filter applied to the audio input
Copy code
# Example Python: choose BVC or Telephony BVC based on participant kind
# (Conceptual snippet — adapt imports and session creation to your app)

from livekit import rtc, room_io, noise_cancellation

async def start_session_for_participant(participant):
    # participant.kind is either rtc.ParticipantKind.PARTICIPANT_KIND_SIP or other kinds
    if participant.kind == rtc.ParticipantKind.PARTICIPANT_KIND_SIP:
        filter = noise_cancellation.BVCTelephony()
    else:
        filter = noise_cancellation.BVC()

    room_options = room_io.RoomOptions(
        audio_input=room_io.AudioInputOptions(noise_cancellation=filter)
    )

    # session represents your agent/worker session that will send/receive audio
    session = await create_session_for_participant(participant)  # implement this per your app
    await session.start(room_options=room_options)

    return session
If you want, I can: • Provide a more complete runnable example showing session creation and imports for your specific LiveKit SDK version. • Show how to disable
krisp_enabled
on SIP trunks/frontends if your setup currently uses Krisp, to avoid double-processing. Which would you prefer?