Spaces:
Running
Running
Update conver.py
Browse files
conver.py
CHANGED
@@ -166,19 +166,22 @@ class URLToAudioConverter:
|
|
166 |
return final_output, conversation_text
|
167 |
|
168 |
async def raw_text_to_audio(self, text: str, voice_1: str, voice_2: str) -> Tuple[str, str]:
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
os.remove(f)
|
184 |
return text, output_file
|
|
|
|
|
|
|
|
|
|
166 |
return final_output, conversation_text
|
167 |
|
168 |
async def raw_text_to_audio(self, text: str, voice_1: str, voice_2: str) -> Tuple[str, str]:
|
169 |
+
try:
|
170 |
+
# 1. Guardar en el root del repo (sin subcarpetas)
|
171 |
+
output_file = f"podcast_{hashlib.md5(text.encode()).hexdigest()[:8]}.mp3"
|
172 |
+
|
173 |
+
# 2. Nombre corto de la voz (sin sufijos)
|
174 |
+
voice = voice_1.split(" - ")[0] # Ej: "es-ES-ElviraNeural"
|
175 |
+
|
176 |
+
# 3. Generar audio y verificar
|
177 |
+
communicate = edge_tts.Communicate(text, voice)
|
178 |
+
await communicate.save(output_file)
|
179 |
+
|
180 |
+
if not os.path.exists(output_file) or os.path.getsize(output_file) == 0:
|
181 |
+
raise RuntimeError("El archivo no se generó correctamente")
|
182 |
+
|
|
|
183 |
return text, output_file
|
184 |
+
|
185 |
+
except Exception as e:
|
186 |
+
print(f"ERROR: {str(e)}")
|
187 |
+
return f"Error: {str(e)}", None
|