artificialguybr commited on
Commit
07fdf2c
1 Parent(s): d36719a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -86,19 +86,15 @@ 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
- 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]
95
  translator = Translator()
96
- try:
97
- translated_text = translator.translate(whisper_text, src=whisper_language, dest=target_language_code).text
98
- print(translated_text)
99
- except AttributeError as e:
100
- print("Failed to translate text. Likely an issue with token extraction in the Google Translate API.")
101
- translated_text = "Translation failed due to API issue."
102
 
103
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1")
104
  tts.to('cuda')
 
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=4)
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]
95
  translator = Translator()
96
+ translated_text = translator.translate(whisper_text, src=whisper_language, dest=target_language_code).text
97
+ print(translated_text)
 
 
 
 
98
 
99
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1")
100
  tts.to('cuda')