Skip to content

Instantly share code, notes, and snippets.

@lewangdev
Created October 24, 2023 14:13
Show Gist options
  • Save lewangdev/b28f42f2f672245419b9f52d7c525c17 to your computer and use it in GitHub Desktop.
Save lewangdev/b28f42f2f672245419b9f52d7c525c17 to your computer and use it in GitHub Desktop.

Revisions

  1. lewangdev created this gist Oct 24, 2023.
    35 changes: 35 additions & 0 deletions edge_tts_voices.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    import asyncio

    from edge_tts import list_voices

    async def print_voices() -> None:
    """Print all available voices."""
    voices = await list_voices()
    voices = sorted(voices, key=lambda voice: voice["ShortName"])
    print("| Name | Gender | Language |")
    print("| :--- | :----- | :--------|")
    for idx, voice in enumerate(voices):
    if idx != 0:
    pass

    cols = None
    for key in voice.keys():
    if key in (
    "SuggestedCodec",
    "FriendlyName",
    "Status",
    "VoiceTag",
    "Name",
    "Locale",
    ):
    continue
    pretty_key_name = key if key != "ShortName" else "Name"
    if pretty_key_name == 'Name':
    cols = []
    cols.append(voice[key])

    if pretty_key_name == 'Gender':
    print(f"| {cols[0]} | {cols[1]} | {'-'.join(cols[0].split('-')[0:2])} |")

    if __name__ == "__main__":
    asyncio.run(print_voices())