Skip to content

Commit

Permalink
fixed empty transcript case
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Dec 31, 2023
1 parent bff96b7 commit 296b95e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion daras_ai_v2/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 296b95e

Please sign in to comment.