RASMUS commited on
Commit
9a156e7
1 Parent(s): 231a341

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -37,13 +37,21 @@ def speech_to_text(audio_path, whisper_model):
37
  break
38
  print(audio_path)
39
  try:
40
-
41
- _,file_ending = os.path.splitext(f'{audio_path}')
42
- print(f'file enging is {file_ending}')
43
- print("starting conversion to wav")
44
- new_path = audio_path.replace(file_ending, "_converted.wav")
45
- os.system(f'ffmpeg -i "{audio_path}" -ar 16000 -y -ac 1 -c:a pcm_s16le "{new_path}"')
46
- print("conversion to wav ready")
 
 
 
 
 
 
 
 
47
 
48
  except Exception as e:
49
  raise RuntimeError(f'Error Running inference with local model: {e}') from e
 
37
  break
38
  print(audio_path)
39
  try:
40
+ retry_cnt = 0
41
+ for retry_cnt in range(3):
42
+ try:
43
+ _,file_ending = os.path.splitext(f'{audio_path}')
44
+ print(f'file enging is {file_ending}')
45
+ print("starting conversion to wav")
46
+ new_path = audio_path.replace(file_ending, "_converted.wav")
47
+ os.system(f'ffmpeg -i "{audio_path}" -ar 16000 -y -ac 1 -c:a pcm_s16le "{new_path}"')
48
+ print("conversion to wav ready")
49
+ break
50
+ except Exception as e:
51
+ time.sleep(0.5)
52
+ retry_cnt +=1
53
+ if retry_cnt == 3:
54
+ pass
55
 
56
  except Exception as e:
57
  raise RuntimeError(f'Error Running inference with local model: {e}') from e