I am using below xample where on inactivity for 12...
# ask-ai
f
I am using below xample where on inactivity for 12.5 second agenet respond. but its sound is not audible. audio get generate by is audible. import asyncio import logging from dotenv import load_dotenv from livekit.agents import ( Agent, AgentSession, JobContext, UserStateChangedEvent, WorkerOptions, cli, ) from livekit.plugins import cartesia, deepgram, openai, silero logger = logging.getLogger("get-email-agent") load_dotenv() async def entrypoint(ctx: JobContext): session = AgentSession( vad=silero.VAD.load(), llm=openai.LLM(model="gpt-4o-mini"), stt=deepgram.STT(), tts=cartesia.TTS(), user_away_timeout=12.5, ) inactivity_task: asyncio.Task | None = None async def user_presence_task(): # try to ping the user 3 times, if we get no answer, close the session for _ in range(3): await session.generate_reply( instructions=( "The user has been inactive. Politely check if the user is still present, and " "gently guide the conversation back toward your intended goal." ) ) await asyncio.sleep(10) await asyncio.shield(session.aclose()) ctx.delete_room() @session.on("user_state_changed") def _user_state_changed(ev: UserStateChangedEvent): nonlocal inactivity_task if ev.new_state == "away": inactivity_task = asyncio.create_task(user_presence_task()) return # ev.new_state: listening, speaking, .. if inactivity_task is not None: inactivity_task.cancel() await session.start(agent=Agent(instructions="You are a helpful assistant."), room=ctx.room) await ctx.connect() if name == "__main__": cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
t
Thanks for reaching out, R. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thank you for sharing the code snippet. To better assist you, could you clarify the following: This information will help us diagnose the issue more effectively.