Skip to content

Commit 24144a9

Browse files
committed
quality: Add a feature for STT complete timeout
1 parent a2b484c commit 24144a9

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ Conversation options are represented as features. They can be configured from Ap
477477
| `callback_timeout_hour` | The timeout for a callback in hours. Set 0 to disable. | `int` | 3 |
478478
| `phone_silence_timeout_sec` | Amount of silence in secs to trigger a warning message from the assistant. | `int` | 20 |
479479
| `recognition_retry_max` | TThe maximum number of retries for voice recognition. Minimum of 1. | `int` | 3 |
480+
| `recognition_stt_complete_timeout_ms` | The timeout for STT completion in milliseconds. | `int` | 100 |
480481
| `recording_enabled` | Whether call recording is enabled. | `bool` | false |
481482
| `slow_llm_for_chat` | Whether to use the slow LLM for chat. | `bool` | false |
482483
| `vad_cutoff_timeout_ms` | The cutoff timeout for voice activity detection in milliseconds. | `int` | 250 |

app/helpers/call_llm.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
answer_hard_timeout_sec,
2626
answer_soft_timeout_sec,
2727
phone_silence_timeout_sec,
28+
recognition_stt_complete_timeout_ms,
2829
vad_cutoff_timeout_ms,
2930
vad_silence_timeout_ms,
3031
)
@@ -260,7 +261,10 @@ async def _response_callback(_retry: bool = False) -> None:
260261

261262
# Wait the complete recognition for 50ms maximum
262263
try:
263-
await asyncio.wait_for(stt_complete_gate.wait(), timeout=0.05)
264+
await asyncio.wait_for(
265+
stt_complete_gate.wait(),
266+
timeout=await recognition_stt_complete_timeout_ms(scheduler) / 1000,
267+
)
264268
except TimeoutError:
265269
logger.debug("Complete recognition timeout, using partial recognition")
266270

app/helpers/features.py

+12
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ async def recognition_retry_max(scheduler: Scheduler) -> int:
139139
)
140140

141141

142+
async def recognition_stt_complete_timeout_ms(scheduler: Scheduler) -> int:
143+
"""
144+
The timeout for STT completion in milliseconds.
145+
"""
146+
return await _default(
147+
default=100,
148+
key="recognition_stt_complete_timeout_ms",
149+
scheduler=scheduler,
150+
type_res=int,
151+
)
152+
153+
142154
async def _default( # noqa: PLR0913
143155
default: T,
144156
key: str,

cicd/bicep/app.bicep

+1
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,7 @@ resource configValues 'Microsoft.AppConfiguration/configurationStores/keyValues@
905905
callback_timeout_hour: 3
906906
phone_silence_timeout_sec: 20
907907
recognition_retry_max: 2
908+
recognition_stt_complete_timeout_ms: 100
908909
recording_enabled: false
909910
slow_llm_for_chat: false
910911
vad_cutoff_timeout_ms: 250

0 commit comments

Comments
 (0)