Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

ux: Let the ops decide the recognition timeout delay

Clémence Lesné2857baa39d2a
diff --git a/helpers/call_utils.py b/helpers/call_utils.py
index 1be7f21..fafca04 100644
--- a/helpers/call_utils.py
+++ b/helpers/call_utils.py
@@ -182,16 +182,14 @@ async def handle_recognize_text(
If `store` is `True`, the text will be stored in the call messages. Starts by playing text, then the "ready" sound, and finally starts recognizing the response.
"""
- timeout_value = 5 # Wait 5 seconds for the user to speak and end the recognition
contexts = [context] if context else []
-
if not text: # Only recognize
contexts.append(ContextEnum.LAST_CHUNK)
await _handle_recognize_media(
call=call,
client=client,
contexts=contexts,
- end_silence=timeout_value,
+ end_silence=CONFIG.workflow.voice_timeout_after_silence_sec,
style=style,
text=None,
)
@@ -206,7 +204,7 @@ async def handle_recognize_text(
for i, chunk in enumerate(chunks):
end_silence = None
if i == len(chunks) - 1: # Last chunk
- end_silence = timeout_value
+ end_silence = CONFIG.workflow.voice_timeout_after_silence_sec
if timeout_error:
contexts.append(ContextEnum.LAST_CHUNK)
await _handle_recognize_media(
diff --git a/helpers/config_models/workflow.py b/helpers/config_models/workflow.py
index 31af4c7..34abe73 100644
--- a/helpers/config_models/workflow.py
+++ b/helpers/config_models/workflow.py
@@ -133,6 +133,7 @@ class WorkflowModel(BaseModel):
intelligence_soft_timeout_sec: int = 30 # 30 seconds
max_voice_recognition_retry: int = 3
use_slow_llm_for_chat_as_default: bool = True
+ voice_timeout_after_silence_sec: int = 2 # 2 seconds
def _fields_to_pydantic(name: str, fields: list[ClaimFieldModel]) -> type[BaseModel]: