Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,7 +19,16 @@ model_files = {
|
|
19 |
tts_model_path = "./xtts_v2"
|
20 |
|
21 |
# Initialize TTS model
|
22 |
-
tts = TTS(tts_model_path, gpu=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
|
25 |
for filename, url in model_files.items():
|
@@ -74,9 +83,17 @@ class translation:
|
|
74 |
translation = response.json()[0]["translations"][0]["text"]
|
75 |
return translation
|
76 |
|
|
|
|
|
|
|
|
|
77 |
def generate_audio(self, translated_text):
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
|
81 |
def translate_video(self):
|
82 |
audio_path = self.extract_audio()
|
|
|
19 |
tts_model_path = "./xtts_v2"
|
20 |
|
21 |
# Initialize TTS model
|
22 |
+
# tts = TTS(tts_model_path, gpu=True)
|
23 |
+
|
24 |
+
|
25 |
+
# Initialize TTS model with verbose output
|
26 |
+
try:
|
27 |
+
print(f"Initializing TTS model from path: {tts_model_path}")
|
28 |
+
tts = TTS(tts_model_path, gpu=True)
|
29 |
+
print("TTS model initialized successfully.")
|
30 |
+
except Exception as e:
|
31 |
+
print(f"Error initializing TTS model: {e}")
|
32 |
|
33 |
|
34 |
for filename, url in model_files.items():
|
|
|
83 |
translation = response.json()[0]["translations"][0]["text"]
|
84 |
return translation
|
85 |
|
86 |
+
# def generate_audio(self, translated_text):
|
87 |
+
# tts.tts_to_file(text=translated_text, speaker_wav='output_audio.wav', file_path="output_synth.wav", language=self.tran_code)
|
88 |
+
# return "output_synth.wav"
|
89 |
+
|
90 |
def generate_audio(self, translated_text):
|
91 |
+
try:
|
92 |
+
tts.tts_to_file(text=translated_text, speaker_wav='output_audio.wav', file_path="output_synth.wav", language=self.tran_code)
|
93 |
+
return "output_synth.wav"
|
94 |
+
except Exception as e:
|
95 |
+
print(f"Error generating audio: {e}")
|
96 |
+
raise
|
97 |
|
98 |
def translate_video(self):
|
99 |
audio_path = self.extract_audio()
|