Spaces:
Runtime error
Runtime error
artificialguybr
commited on
Commit
•
2ea769d
1
Parent(s):
98a98e1
Update app.py
Browse files
app.py
CHANGED
@@ -86,9 +86,18 @@ def process_video(radio, video, target_language, has_closeup_face):
|
|
86 |
shell_command = f"ffmpeg -y -i {run_uuid}_output_audio.wav -af lowpass=3000,highpass=100 {run_uuid}_output_audio_final.wav".split(" ")
|
87 |
subprocess.run([item for item in shell_command], capture_output=False, text=True, check=True)
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
language_mapping = {'English': 'en', 'Spanish': 'es', 'French': 'fr', 'German': 'de', 'Italian': 'it', 'Portuguese': 'pt', 'Polish': 'pl', 'Turkish': 'tr', 'Russian': 'ru', 'Dutch': 'nl', 'Czech': 'cs', 'Arabic': 'ar', 'Chinese (Simplified)': 'zh-cn'}
|
94 |
target_language_code = language_mapping[target_language]
|
|
|
86 |
shell_command = f"ffmpeg -y -i {run_uuid}_output_audio.wav -af lowpass=3000,highpass=100 {run_uuid}_output_audio_final.wav".split(" ")
|
87 |
subprocess.run([item for item in shell_command], capture_output=False, text=True, check=True)
|
88 |
|
89 |
+
print("Attempting to transcribe with Whisper...")
|
90 |
+
try:
|
91 |
+
segments, info = model.transcribe(f"{run_uuid}_output_audio_final.wav", beam_size=5)
|
92 |
+
whisper_text = " ".join(segment.text for segment in segments)
|
93 |
+
whisper_language = info.language
|
94 |
+
print(f"Transcription successful: {whisper_text}")
|
95 |
+
except RuntimeError as e:
|
96 |
+
print(f"RuntimeError encountered: {str(e)}")
|
97 |
+
if "CUDA failed with error device-side assert triggered" in str(e):
|
98 |
+
gr.Warning("Error. Space need to restart. Please retry in a minute")
|
99 |
+
# Restart the script
|
100 |
+
api.restart_space(repo_id=repo_id)
|
101 |
|
102 |
language_mapping = {'English': 'en', 'Spanish': 'es', 'French': 'fr', 'German': 'de', 'Italian': 'it', 'Portuguese': 'pt', 'Polish': 'pl', 'Turkish': 'tr', 'Russian': 'ru', 'Dutch': 'nl', 'Czech': 'cs', 'Arabic': 'ar', 'Chinese (Simplified)': 'zh-cn'}
|
103 |
target_language_code = language_mapping[target_language]
|