Spaces:
Build error
Build error
Update conver.py
Browse files165 unmodified lines166167168169170171172173174175176177178179180181182183184165 unmodified linesreturn final_output, conversation_textasync def raw_text_to_audio(self, text: str, voice_1: str, voice_2: str) -> Tuple[str, str]:conversation = {"conversation": [{"speaker": "Host", "text": text},{"speaker": "Co-host", "text": "(Continuación del tema)"}]}audio_files, folder_name = await self.text_to_speech(conversation, voice_1, voice_2)combined_audio = self.combine_audio_files(audio_files)music_path = "assets/musica.mp3"tags_paths = ["assets/tag.mp3", "assets/tag2.mp3"]final_audio = self.add_background_music_and_tags(combined_audio, music_path, tags_paths)output_file = os.path.join(folder_name, "raw_podcast_with_music.mp3")final_audio.export(output_file, format="mp3")for f in audio_files:os.remove(f)return text, output_file165 unmodified lines166167168169170171172173174175176177178179180181182183184185186187165 unmodified linesreturn final_output, conversation_textasync def raw_text_to_audio(self, text: str, voice_1: str, voice_2: str) -> Tuple[str, str]:try:# 1. Guardar en el root del repo (sin subcarpetas)output_file = f"podcast_{hashlib.md5(text.encode()).hexdigest()[:8]}.mp3"# 2. Nombre corto de la voz (sin sufijos)voice = voice_1.split(" - ")[0] # Ej: "es-ES-ElviraNeural"# 3. Generar audio y verificarcommunicate = edge_tts.Communicate(text, voice)await communicate.save(output_file)if not os.path.exists(output_file) or os.path.getsize(output_file) == 0:raise RuntimeError("El archivo no se generó correctamente")return text, output_fileexcept Exception as e:print(f"ERROR: {str(e)}")return f"Error: {str(e)}", None
conver.py+18-15