wide-dress-57902
08/16/2025, 9:07 PMtall-airline-16756
08/16/2025, 9:07 PMtall-airline-16756
08/16/2025, 9:08 PMlivekit-plugins-noise-cancellation
package, which includes the BVCTelephony model. Just run this command:
pip install "livekit-plugins-noise-cancellation~=0.2"
2. Next, import the Noise Cancellation Module: In your Python code, bring in the noise cancellation module like this:
from livekit.plugins import noise_cancellation
3. Then, set up your Room Input Options: When you start your AgentSession
, make sure to include the BVCTelephony model in the RoomInputOptions
. This one’s specially tuned for telephony:
await session.start(
agent=agent,
room=ctx.room,
room_input_options=room_io.RoomInputOptions(
noise_cancellation=noise_cancellation.BVCTelephony(),
),
)
And that’s it! Following these steps will help you add BVCTelephony noise cancellation to your LiveKit app, making your audio much clearer for telephony scenarios. If you run into any questions, feel free to ask—I’m here to help!wide-dress-57902
08/16/2025, 9:12 PMtall-airline-16756
08/16/2025, 9:13 PMRoomInputOptions
object in LiveKit is a handy configuration class that helps you decide how an agent handles input from participants in a room. It gives you detailed control over different parts of input processing, including:
• Input Types Configuration:
- Text Input: You can turn text input handling on or off.
- Audio Input: Manage audio settings like noise cancellation, sample rate, and channel count.
- Video Input: Let the agent receive video when you enable this.
• Participant Management: Choose which types of participants (like agents or regular users) the agent should listen to for input.
• Advanced Audio Options: Includes features like pre-connect audio handling with timeout settings and noise cancellation options such as BVC (Background Voice Cancellation) to boost audio quality.
• Session Control: Decide if the session should close when a linked participant disconnects for certain reasons.
Here’s a simple example to show you how it works:
from livekit.agents import RoomInputOptions
from livekit.plugins import noise_cancellation
# Example configuration
input_options = RoomInputOptions(
noise_cancellation=noise_cancellation.BVC(),
participant_kinds=[rtc.ParticipantKind.PARTICIPANT_KIND_AGENT],
video_enabled=True
)
# Start agent session with the options
await session.start(
agent=MyAgent(),
room=ctx.room,
room_input_options=input_options
)
This object is really helpful for tailoring how your app handles inputs and manages participant interactions in a LiveKit room. If you have any questions or want to explore more options, just let me know!wide-dress-57902
08/16/2025, 9:29 PMtall-airline-16756
08/16/2025, 9:30 PMdetected_answering_machine
tool to leave a message and then hang up. Here’s an example:
@function_tool
async def detected_answering_machine(self):
<http://logger.info|logger.info>(f"detected answering machine for {self.participant.identity}")
await self.session.generate_reply(
instructions="Leave a voicemail message letting the user know you'll call back later."
)
await asyncio.sleep(0.5)
await self.hangup()
2. Keep an Eye on Silence:
Monitoring silence can help spot voicemail systems. Check this out:
import asyncio
import time
SILENCE_THRESHOLD = 5 # seconds
async def monitor_interaction():
while True:
if time.time() - user_last_spoke_time > SILENCE_THRESHOLD:
<http://logger.info|logger.info>("silent for too long! disconnecting")
try:
await ctx.room.disconnect()
except Exception as e:
logger.exception("Error while ending call")
await asyncio.sleep(1)
3. Mix It Up for Better Accuracy:
Combining silence monitoring with some LLM-based analysis can really boost detection. Here’s how:
async def monitor_interaction():
while True:
if time.time() - user_last_spoke_time > SILENCE_THRESHOLD:
<http://logger.info|logger.info>("Attempting LLM-based voicemail detection")
await ctx.session.generate_reply(
instructions="Analyzing the call to detect voicemail..."
)
detection_result = await llm.detect_voicemail()
if detection_result:
await detected_answering_machine()
await asyncio.sleep(1)
Just a heads up—make sure to tweak the silence threshold and test with different voicemail systems so it works smoothly. And hey, if you have any questions or want a hand with this, I’m here to help!
Sources: Agent Testing & Evaluation | livekit/livekit_composite | DeepWiki | Agents telephony integration | LiveKit Docs | How to detect and handle silence during calls | agent.py | Speech & Audio Processing | livekit/livekit_composite | DeepWiki