Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!
Python
quality: Add a feature for STT complete timeout
Clémence Lesné24144a9ceb99
diff --git a/README.md b/README.mdindex 4f837f0..8a6b75d 100644--- a/README.md+++ b/README.md@@ -477,6 +477,7 @@ Conversation options are represented as features. They can be configured from Ap| `callback_timeout_hour` | The timeout for a callback in hours. Set 0 to disable. | `int` | 3 || `phone_silence_timeout_sec` | Amount of silence in secs to trigger a warning message from the assistant. | `int` | 20 || `recognition_retry_max` | TThe maximum number of retries for voice recognition. Minimum of 1. | `int` | 3 |+| `recognition_stt_complete_timeout_ms` | The timeout for STT completion in milliseconds. | `int` | 100 || `recording_enabled` | Whether call recording is enabled. | `bool` | false || `slow_llm_for_chat` | Whether to use the slow LLM for chat. | `bool` | false || `vad_cutoff_timeout_ms` | The cutoff timeout for voice activity detection in milliseconds. | `int` | 250 |diff --git a/app/helpers/call_llm.py b/app/helpers/call_llm.pyindex 0b9ff67..5c6ef00 100644--- a/app/helpers/call_llm.py+++ b/app/helpers/call_llm.py@@ -25,6 +25,7 @@ from app.helpers.features import (answer_hard_timeout_sec,answer_soft_timeout_sec,phone_silence_timeout_sec,+ recognition_stt_complete_timeout_ms,vad_cutoff_timeout_ms,vad_silence_timeout_ms,)@@ -260,7 +261,10 @@ async def load_llm_chat( # noqa: PLR0913, PLR0915# Wait the complete recognition for 50ms maximumtry:- await asyncio.wait_for(stt_complete_gate.wait(), timeout=0.05)+ await asyncio.wait_for(+ stt_complete_gate.wait(),+ timeout=await recognition_stt_complete_timeout_ms(scheduler) / 1000,+ )except TimeoutError:logger.debug("Complete recognition timeout, using partial recognition")diff --git a/app/helpers/features.py b/app/helpers/features.pyindex 1aeb409..8465868 100644--- a/app/helpers/features.py+++ b/app/helpers/features.py@@ -139,6 +139,18 @@ async def recognition_retry_max(scheduler: Scheduler) -> int:)+async def recognition_stt_complete_timeout_ms(scheduler: Scheduler) -> int:+ """+ The timeout for STT completion in milliseconds.+ """+ return await _default(+ default=100,+ key="recognition_stt_complete_timeout_ms",+ scheduler=scheduler,+ type_res=int,+ )++async def _default( # noqa: PLR0913default: T,key: str,diff --git a/cicd/bicep/app.bicep b/cicd/bicep/app.bicepindex e30b926..60d4206 100644--- a/cicd/bicep/app.bicep+++ b/cicd/bicep/app.bicep@@ -905,6 +905,7 @@ resource configValues 'Microsoft.AppConfiguration/configurationStores/keyValues@callback_timeout_hour: 3phone_silence_timeout_sec: 20recognition_retry_max: 2+ recognition_stt_complete_timeout_ms: 100recording_enabled: falseslow_llm_for_chat: falsevad_cutoff_timeout_ms: 250