crooked-tiger-31253
07/24/2025, 1:36 AMtall-airline-16756
07/24/2025, 1:36 AMtall-airline-16756
07/24/2025, 1:37 AMmin_consecutive_speech_delay parameter when initializing your AgentSession. This enforces a minimum delay (in seconds) between consecutive speech utterances.
Here’s an example:
session = AgentSession(
min_consecutive_speech_delay=5.0, # 5-second delay between speech
# other parameters...
)
Alternatively, you can implement custom logic for more granular control. For example:
import asyncio
class TimedAgent(Agent):
def __init__(self):
super().__init__(
# agent configuration...
)
self.last_speech_time = 0
self.speech_delay = 5.0 # 5-second delay
async def controlled_speech(self, text):
current_time = time.time()
time_since_last = current_time - self.last_speech_time
if time_since_last < self.speech_delay:
wait_time = self.speech_delay - time_since_last
await asyncio.sleep(wait_time)
await self.session.say(text, allow_interruptions=False)
self.last_speech_time = time.time()
You can also explore endpointing delays for additional control:
session = AgentSession(
min_endpointing_delay=2.0, # Wait 2 seconds after potential end-of-utterance
max_endpointing_delay=8.0, # Maximum wait time before terminating turn
# other parameters...
)
The min_consecutive_speech_delay parameter is the simplest and most direct method to enforce a fixed delay between agent speech utterances.
Sources: tests/test_agent_session.py | basics/uninterruptable.py