Skip to content

Commit

Permalink
extra retry for asr audio
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Jul 14, 2024
1 parent 855eeeb commit 09bb29d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion daras_ai_v2/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,15 @@ def download_youtube_to_wav(youtube_url: str) -> bytes:

def audio_url_to_wav(audio_url: str) -> tuple[str, int]:
r = requests.get(audio_url)
raise_for_status(r, is_user_url=True)
try:
raise_for_status(r, is_user_url=True)
except requests.HTTPError:
# wait 3 seconds and try again (handles cases where the url has just been uploaded but cache is not updated yet, e.g. for Twilio)
from time import sleep

sleep(3)
r = requests.get(audio_url)
raise_for_status(r, is_user_url=True)

wavdata, size = audio_bytes_to_wav(r.content)
if not wavdata:
Expand Down

0 comments on commit 09bb29d

Please sign in to comment.