artificialguybr commited on
Commit
4eae89a
1 Parent(s): 233c677

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -54,8 +54,15 @@ def process_video(video, high_quality, target_language):
54
  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'}
55
  target_language_code = language_mapping[target_language]
56
  translator = Translator()
57
- translated_text = translator.translate(whisper_text, src=whisper_language, dest=target_language_code).text
58
-
 
 
 
 
 
 
 
59
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1")
60
  tts.to('cuda') # Replacing deprecated gpu=True
61
  tts.tts_to_file(translated_text, speaker_wav='output_audio_final.wav', file_path="output_synth.wav", language=target_language_code)
 
54
  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'}
55
  target_language_code = language_mapping[target_language]
56
  translator = Translator()
57
+ try:
58
+ translated_text = translator.translate(whisper_text, src=whisper_language, dest=target_language_code).text
59
+ except AttributeError as e:
60
+ print("Failed to translate text. Here's the error:")
61
+ print(e)
62
+ print("Response text for debugging:")
63
+ print(r.text) # Assuming `r` is the response object
64
+ translated_text = "Translation failed"
65
+
66
  tts = TTS("tts_models/multilingual/multi-dataset/xtts_v1")
67
  tts.to('cuda') # Replacing deprecated gpu=True
68
  tts.tts_to_file(translated_text, speaker_wav='output_audio_final.wav', file_path="output_synth.wav", language=target_language_code)