artificialguybr commited on
Commit
d36719a
1 Parent(s): 04fc8d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -86,21 +86,9 @@ 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
- print("FFmpeg command completed.")
90
-
91
- # Execute Whisper transcription
92
- print("Attempting to transcribe with Whisper...")
93
- try:
94
- segments, info = model.transcribe(f"{run_uuid}_output_audio_final.wav", beam_size=5)
95
- whisper_text = " ".join(segment.text for segment in segments)
96
- whisper_language = info.language
97
- print(f"Transcription successful: {whisper_text}")
98
- except RuntimeError as e:
99
- print(f"RuntimeError encountered: {str(e)}")
100
- if "CUDA failed with error device-side assert triggered" in str(e):
101
- gr.Warning("Error. Space need to restart. Please retry in a minute")
102
- # Restart the script
103
- api.restart_space(repo_id=repo_id)
104
 
105
  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'}
106
  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
+ segments, info = model.transcribe(f"{run_uuid}_output_audio_final.wav", beam_size=5)
90
+ whisper_text = " ".join(segment.text for segment in segments)
91
+ whisper_language = info.language
 
 
 
 
 
 
 
 
 
 
 
 
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]