diff --git a/README.md b/README.md index 4f837f01..8a6b75d3 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.py index 0b9ff67a..5c6ef009 100644 --- a/app/helpers/call_llm.py +++ b/app/helpers/call_llm.py @@ -25,6 +25,7 @@ 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 _response_callback(_retry: bool = False) -> None: # Wait the complete recognition for 50ms maximum try: - 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.py index 1aeb409d..84658683 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: PLR0913 default: T, key: str, diff --git a/cicd/bicep/app.bicep b/cicd/bicep/app.bicep index e30b9262..60d42066 100644 --- a/cicd/bicep/app.bicep +++ b/cicd/bicep/app.bicep @@ -905,6 +905,7 @@ resource configValues 'Microsoft.AppConfiguration/configurationStores/keyValues@ callback_timeout_hour: 3 phone_silence_timeout_sec: 20 recognition_retry_max: 2 + recognition_stt_complete_timeout_ms: 100 recording_enabled: false slow_llm_for_chat: false vad_cutoff_timeout_ms: 250