aloof-account-63566
05/09/2025, 8:08 AMtall-airline-16756
05/09/2025, 8:08 AMtall-airline-16756
05/09/2025, 8:08 AMAudioEnergyFilter
class is used for this purpose. It calculates the root mean square (RMS) of audio data to determine if speech has started. If the RMS exceeds a certain threshold, it transitions from a silent state to a speaking state. Let me know if you need further details or clarification!
Sources: Tree View: | dse-workbenchaloof-account-63566
05/09/2025, 8:09 AMtall-airline-16756
05/09/2025, 8:10 AMimport asyncio
import time
SILENCE_THRESHOLD = 5 # seconds
async def entrypoint(ctx: JobContext):
user_last_spoke_time = time.time()
monitor_task = None
async def monitor_interaction():
while True:
if time.time() - user_last_spoke_time > SILENCE_THRESHOLD:
# Prompt the user here
await agent.say("Are you still there?")
await asyncio.sleep(1)
@agent.on("user_started_speaking")
def on_user_started_speaking(_msg: llm.ChatMessage):
user_last_spoke_time = time.time()
monitor_task = asyncio.create_task(monitor_interaction())
agent.start(ctx.room, participant)
async def on_shutdown():
if monitor_task:
monitor_task.cancel()
ctx.add_shutdown_callback(on_shutdown)
This code monitors the time since the user last spoke and prompts them if the silence exceeds 5 seconds. Let me know if you need further assistance!
Sources: How to detect and handle silence during callsaloof-account-63566
05/09/2025, 8:11 AMtall-airline-16756
05/09/2025, 8:11 AMaloof-account-63566
05/09/2025, 8:13 AMtall-airline-16756
05/09/2025, 8:13 AM