Skip to content

Is there a way to specify the language only, not the voice? #81

Answered by rany2
HubKing asked this question in Q&A
Discussion options

You must be logged in to vote

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

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rany2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants