Use tabulate to pretty print voices (#321)
Signed-off-by: rany <rany2@riseup.net>
This commit is contained in:
1
setup.py
1
setup.py
@@ -6,6 +6,7 @@ setup(
|
|||||||
install_requires=[
|
install_requires=[
|
||||||
"aiohttp>=3.8.0",
|
"aiohttp>=3.8.0",
|
||||||
"certifi>=2023.11.17",
|
"certifi>=2023.11.17",
|
||||||
|
"tabulate>=0.4.4",
|
||||||
"typing-extensions>=4.1.0",
|
"typing-extensions>=4.1.0",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import sys
|
|||||||
from io import TextIOWrapper
|
from io import TextIOWrapper
|
||||||
from typing import Any, TextIO, Union
|
from typing import Any, TextIO, Union
|
||||||
|
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
from . import Communicate, SubMaker, list_voices
|
from . import Communicate, SubMaker, list_voices
|
||||||
|
|
||||||
|
|
||||||
@@ -13,22 +15,17 @@ async def _print_voices(*, proxy: str) -> None:
|
|||||||
"""Print all available voices."""
|
"""Print all available voices."""
|
||||||
voices = await list_voices(proxy=proxy)
|
voices = await list_voices(proxy=proxy)
|
||||||
voices = sorted(voices, key=lambda voice: voice["ShortName"])
|
voices = sorted(voices, key=lambda voice: voice["ShortName"])
|
||||||
for idx, voice in enumerate(voices):
|
headers = ["Name", "Gender", "ContentCategories", "VoicePersonalities"]
|
||||||
if idx != 0:
|
table = [
|
||||||
print()
|
[
|
||||||
|
voice["ShortName"],
|
||||||
for key in voice.keys():
|
voice["Gender"],
|
||||||
if key in (
|
", ".join(voice["VoiceTag"]["ContentCategories"]),
|
||||||
"SuggestedCodec",
|
", ".join(voice["VoiceTag"]["VoicePersonalities"]),
|
||||||
"FriendlyName",
|
]
|
||||||
"Status",
|
for voice in voices
|
||||||
"VoiceTag",
|
]
|
||||||
"Name",
|
print(tabulate(table, headers))
|
||||||
"Locale",
|
|
||||||
):
|
|
||||||
continue
|
|
||||||
pretty_key_name = key if key != "ShortName" else "Name"
|
|
||||||
print(f"{pretty_key_name}: {voice[key]}")
|
|
||||||
|
|
||||||
|
|
||||||
async def _run_tts(args: Any) -> None:
|
async def _run_tts(args: Any) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user