-
Sometimes, I only care about that the text is read in the correct language, no matter which voice it is. For example, I just want "Bonjour" to be read in French, no matter which French voice is used. I tried passing Must I specify a specific voice? |
Beta Was this translation helpful? Give feedback.
Answered by
rany2
May 5, 2023
Replies: 1 comment
-
Yes, you must specify a specific voice. However you could use the VoiceManager which selects a voice for you. For example, #!/usr/bin/env python3
import asyncio
import edge_tts
from edge_tts import VoicesManager
TEXT = "Hoy es un buen día."
OUTPUT_FILE = "spanish.mp3"
async def _main() -> None:
voices = await VoicesManager.create()
voice = voices.find(Gender="Male", Language="es")
# Also supports Locales
# voice = voices.find(Gender="Female", Locale="es-AR")
communicate = edge_tts.Communicate(TEXT, voice[0]["Name"])
await communicate.save(OUTPUT_FILE)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(_main())
finally:
loop.close() |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rany2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, you must specify a specific voice. However you could use the VoiceManager which selects a voice for you. For example,