From 296b95eebdc6090d8930294723ab9b0600f7b999 Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Sun, 31 Dec 2023 13:34:35 -0800 Subject: [PATCH] fixed empty transcript case --- daras_ai_v2/asr.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daras_ai_v2/asr.py b/daras_ai_v2/asr.py index 898ef61be..991054b91 100644 --- a/daras_ai_v2/asr.py +++ b/daras_ai_v2/asr.py @@ -658,7 +658,8 @@ def azure_asr(audio_url: str, language: str): headers={"Ocp-Apim-Subscription-Key": settings.AZURE_SPEECH_KEY}, ) r.raise_for_status() - transcriptions += [r.json()["combinedRecognizedPhrases"][0]["display"]] + combined_phrases: list[dict] = dict(r.json()).get("combinedRecognizedPhrases", [{}]) or [{}] + transcriptions += [combined_phrases[0].get("display", "")] return "\n".join(transcriptions) assert False, "Max polls exceeded, Azure speech did not yield a response"