test(voice): wait on fallback turn completion
This commit is contained in:
@@ -1387,6 +1387,7 @@ def test_media_runtime_voice_v2_uses_streaming_sidecar_for_partial_and_final_asr
|
||||
def test_media_runtime_voice_v2_falls_back_when_streaming_sidecar_is_unavailable():
|
||||
registrations: dict[str, MediaRegistration] = {}
|
||||
turns: list[str] = []
|
||||
turn_ready = threading.Event()
|
||||
|
||||
class _BatchASRProvider(ASRProvider):
|
||||
name = "batch-asr"
|
||||
@@ -1445,6 +1446,7 @@ def test_media_runtime_voice_v2_falls_back_when_streaming_sidecar_is_unavailable
|
||||
plan_reply=lambda session_id, text, metadata, kind: None,
|
||||
process_turn=lambda session_id, transcript_text, language, barge_in, metadata: (
|
||||
turns.append(transcript_text)
|
||||
or turn_ready.set()
|
||||
or VoiceAITurnDecisionOut(
|
||||
language=language or "ru",
|
||||
intent="handoff",
|
||||
@@ -1480,11 +1482,7 @@ def test_media_runtime_voice_v2_falls_back_when_streaming_sidecar_is_unavailable
|
||||
writer.write(encode_audio_packet(silence_frame))
|
||||
await writer.drain()
|
||||
|
||||
deadline = time.time() + 10.0
|
||||
while time.time() < deadline:
|
||||
if turns:
|
||||
break
|
||||
await asyncio.sleep(0.05)
|
||||
assert await asyncio.to_thread(turn_ready.wait, 10.0)
|
||||
|
||||
writer.close()
|
||||
await writer.wait_closed()
|
||||
|
||||
Reference in New Issue
Block a user