Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|