-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtexto_a_audio.py
More file actions
32 lines (28 loc) · 1.11 KB
/
texto_a_audio.py
File metadata and controls
32 lines (28 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import edge_tts
import asyncio
async def generar_audio():
try:
# Leer el guion del archivo de texto
with open("podcast_script.txt", "r", encoding="utf-8") as f:
texto = f.read()
# Crear el SSML para generar el audio con una sola voz más amigable
ssml_text = f"""
<speak>
<voice name="en-US-JennyNeural">
<prosody rate="5%" pitch="10%">
{texto}
</prosody>
</voice>
</speak>
"""
print("Generando audio con Edge-TTS...")
tts = edge_tts.Communicate(ssml_text, voice="en-US-JennyNeural") # Usamos una voz más amigable
await tts.save("podcast_experto_ingles.mp3")
print("Podcast guardado en 'podcast_experto_ingles.mp3'.")
except edge_tts.exceptions.NoAudioReceived as e:
print("Error: No audio received. Please check the SSML format or voice parameters.")
print(str(e))
except Exception as e:
print("An error occurred:", str(e))
if __name__ == "__main__":
asyncio.run(generar_audio())