my agent is very sensitive to background noise - h...
# ask-ai
a
my agent is very sensitive to background noise - how to reduce this
t
Thanks for reaching out, Shajahan. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to reduce your agent's sensitivity to background noise — here's what you can do. 1) Enable Background Voice Cancellation (BVC) on the agent (recommended) • BVC removes background noise and secondary voices and is optimized for voice AI agents. • Python example:
Copy code
from livekit.plugins import noise_cancellation
from livekit.agents.voice import room_io

await session.start(
  room=ctx.room,
  agent=agent,
  room_options=room_io.RoomOptions(
    audio_input=room_io.AudioInputOptions(
      noise_cancellation=noise_cancellation.BVC(),
    ),
  ),
)
• Node.js example:
Copy code
import { BackgroundVoiceCancellation } from '@livekit/noise-cancellation-node';

await session.start({
  room: ctx.room,
  agent: myAgent,
  inputOptions: {
    noiseCancellation: BackgroundVoiceCancellation(),
  },
});
2) Disable frontend noise cancellation if using BVC • Don’t run frontend NC and BVC at the same time; double-processing can degrade audio quality. 3) Use a reliable VAD (voice activity detection) • Use a VAD (e.g., Silero) to reduce false speech detections and unnecessary turn interruptions. 4) Telephony note • For telephony use cases BVC is not available; use the standard
NC()
model instead. Would you like instructions for your specific SDK (Web, iOS, Android, or server-side agent) or help adding VAD configuration? Sources: Enhanced noise cancellation | LiveKit docs | Agent session | LiveKit docs | Turn detection and interruptions | LiveKit Docs | Agent Builder | LiveKit docs
r
can we apply bvc on gemini realtime model
t
Yes — you can apply BVC to the Gemini Realtime model. BVC runs as a local preprocessing step on inbound audio before it reaches the LLM, so it’s compatible with any realtime model (including Gemini). Use
noise_cancellation.BVC()
(or
BackgroundVoiceCancellation()
in Node) in your agent session’s room input options. For SIP/telephony participants use the telephony variant (
BVCTelephony()
). Would you like the exact code snippet for your SDK (Python, Node, Web, iOS, or Android)? Sources: Enhanced noise cancellation | LiveKit docs | Gemini Live API plugin | LiveKit docs
r
Copy code
session = AgentSession(
            llm=google.realtime.RealtimeModel(
                model="gemini-2.5-flash-native-audio-preview-12-2025",
                # model="gemini-live-2.5-flash-native-audio",
                voice="Aoede",
                temperature=0.8,
            )
        )

await session.start(
    room=ctx.room,
    agent=VoiceAssistant(),
)
what can I add in these two lines that will enhance voice activity detection and noise cancellation
t
You're asking what to add to your snippet to improve VAD and noise cancellation. Add a Silero VAD to the session and BVC in the room options. Example:
Copy code
from livekit.plugins import google, silero, noise_cancellation
from livekit.agents.voice import room_io

session = AgentSession(
    llm=google.realtime.RealtimeModel(
        model="gemini-2.5-flash-native-audio-preview-12-2025",
        voice="Aoede",
        temperature=0.8,
    ),
    vad=silero.VAD.load(),  # improves voice activity / interruption detection
)

await session.start(
    room=ctx.room,
    agent=VoiceAssistant(),
    room_options=room_io.RoomOptions(
        audio_input=room_io.AudioInputOptions(
            noise_cancellation=noise_cancellation.BVC(),  # removes background noise & secondary speakers
        ),
    ),
)
Notes: • Disable any frontend NC if you enable BVC to avoid double-processing. • For telephony participants use
BVCTelephony()
instead. • If you want even better turn detection, I can show how to add a turn detector (e.g., MultilingualModel) and an STT plugin for interim transcripts. Would you like that? Sources: Gemini Live API plugin | LiveKit docs | Enhanced noise cancellation | LiveKit docs | LiveKit turn detector plugin | LiveKit docs | Agent session | LiveKit docs
r
2025-12-15 162201,291 - livekit.agents - INFO - process initialized 162201.291 INFO livekit.agents process initialized {"pid": 73651, "elapsed_time": 1.44} 2025-12-15 162201,291 - asyncio - DEBUG - Using selector: KqueueSelector DEBUG asyncio Using selector: KqueueSelector {"pid": 73651} 2025-12-15 162201,294 - __mp_main__ - INFO - 🚀 Agent entrypoint called for room: voice-bot-room 2025-12-15 162201,294 - __mp_main__ - INFO - 📝 Creating AgentSession with Gemini Realtime model... 2025-12-15 162201,294 - __mp_main__ - INFO - 🚀 Agent entrypoint called for room: voice-bot-room 162201.294 INFO __mp_main__ 🚀 Agent entrypoint called for room: voice-bot-room {"pid": 73651, "job_id": "AJ_C2ukDEgU2ZMz", "room_id": "RM_7Fa28QvoVkNL"} 2025-12-15 162201,294 - __mp_main__ - INFO - 📝 Creating AgentSession with Gemini Realtime model... INFO __mp_main__ 📝 Creating AgentSession with Gemini Realtime model... {"pid": 73651, "job_id": "AJ_C2ukDEgU2ZMz", "room_id": "RM_7Fa28QvoVkNL"} 2025-12-15 162201,323 - __mp_main__ - ERROR - ❌ Error in agent entrypoint: RealtimeModel.__init__() got an unexpected keyword argument 'vad' Traceback (most recent call last): File "/Users/gaurav.jarwal/livekit-gemini-voicebot/agent.py", line 188, in my_agent llm=google.realtime.RealtimeModel( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: RealtimeModel.__init__() got an unexpected keyword argument 'vad' 2025-12-15 162201,323 - __mp_main__ - INFO - 🔚 Agent session ended for room: voice-bot-room 2025-12-15 162201,323 - __mp_main__ - ERROR - ❌ Error in agent entrypoint: RealtimeModel.__init__() got an unexpected keyword argument 'vad' Traceback (most recent call last): File "/Users/gaurav.jarwal/livekit-gemini-voicebot/agent.py", line 188, in my_agent llm=google.realtime.RealtimeModel( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: RealtimeModel.__init__() got an unexpected keyword argument 'vad' Traceback (most recent call last): File "/Users/gaurav.jarwal/livekit-gemini-voicebot/agent.py", line 188, in my_agent llm=google.realtime.RealtimeModel( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: RealtimeModel.__init__() got an unexpected keyword argument 'vad' 2025-12-15 162201,323 - livekit.agents - ERROR - unhandled exception while running the job task Traceback (most recent call last): File "/Users/gaurav.jarwal/.pyenv/versions/3.12.7/lib/python3.12/site-packages/opentelemetry/util/_decorator.py", line 71, in async_wrapper return await func(*args, **kwargs) # type: ignore ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/gaurav.jarwal/.pyenv/versions/3.12.7/lib/python3.12/site-packages/livekit/agents/ipc/job_proc_lazy_main.py", line 286, in _traceable_entrypoint await self._job_entrypoint_fnc(job_ctx) File "/Users/gaurav.jarwal/livekit-gemini-voicebot/agent.py", line 188, in my_agent llm=google.realtime.RealtimeModel( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: RealtimeModel.__init__() got an unexpected keyword argument 'vad' 162201.323 ERROR __mp_main__ ❌ Error in agent entrypoint: RealtimeModel.__init__() got an unexpected keyword argument 'vad' Traceback (most recent call last): File "/Users/gaurav.jarwal/livekit-gemini-voicebot/agent.py", line 188, in my_agent llm=google.realtime.RealtimeModel( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: RealtimeModel.__init__() got an unexpected keyword argument 'vad' {"pid": 73651, "job_id": "AJ_C2ukDEgU2ZMz", "room_id": "RM_7Fa28QvoVkNL"} Traceback (most recent call last): File "/Users/gaurav.jarwal/livekit-gemini-voicebot/agent.py", line 188, in my_agent llm=google.realtime.RealtimeModel( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: RealtimeModel.__init__() got an unexpected keyword argument 'vad' 2025-12-15 162201,323 - __mp_main__ - INFO - 🔚 Agent session ended for room: voice-bot-room INFO __mp_main__ 🔚 Agent session ended for room: voice-bot-room {"pid": 73651, "job_id": "AJ_C2ukDEgU2ZMz", "room_id": "RM_7Fa28QvoVkNL"} 2025-12-15 162201,323 - livekit.agents - ERROR - unhandled exception while running the job task Traceback (most recent call last):
t
Thanks — that TypeError happens because
vad
is not a parameter of
RealtimeModel
. Pass VAD to
AgentSession
and put noise cancellation in
session.start()
room options. Use Silero VAD plus BVC for best results. Corrected minimal example:
Copy code
from livekit.agents import AgentSession
from livekit.plugins import google, silero, noise_cancellation
from livekit.agents.voice import room_io

session = AgentSession(
    llm=google.realtime.RealtimeModel(
        model="gemini-2.5-flash-native-audio-preview-12-2025",
        voice="Aoede",
        temperature=0.8,
    ),
    vad=silero.VAD.load(),  # ← pass VAD here
)

await session.start(
    room=ctx.room,
    agent=VoiceAssistant(),
    room_options=room_io.RoomOptions(
        audio_input=room_io.AudioInputOptions(
            noise_cancellation=noise_cancellation.BVC(),  # ← apply BVC here
        ),
    ),
)
Quick tips: • Disable any frontend NC if you enable BVC to avoid double-processing. • For telephony participants use
BVCTelephony()
. • If you want stronger turn-detection later, I can show how to add
turn_detection
+ an STT plugin. Do you want me to validate your current imports/installed packages or show the commands to download Silero/BVC model weights? Sources: Enhanced noise cancellation | LiveKit docs