Slight cleanup of util code & misc changes

This commit is contained in:
rany2 2023-01-05 06:40:56 +02:00
parent 9355ef7c02
commit b5b7a42354
3 changed files with 21 additions and 27 deletions

View File

@ -7,5 +7,11 @@ from .communicate import Communicate
from .list_voices import VoicesManager, list_voices
from .submaker import SubMaker
__all__ = ["Communicate", "VoicesManager", "SubMaker", "exceptions", "list_voices"]
__all__ = [
"Communicate",
"SubMaker",
"VoicesManager",
"exceptions",
"list_voices",
]
__version__ = "6.0.5"

View File

@ -1,5 +1,5 @@
"""
Constants for the edgeTTS package.
Constants for the Edge TTS project.
"""
TRUSTED_CLIENT_TOKEN = "6A5AA1D4EAFF4E9FB37E23D68491D6F4"

View File

@ -74,27 +74,17 @@ async def _async_main() -> None:
parser.add_argument(
"-v",
"--voice",
help="voice for TTS. " "Default: en-US-AriaNeural",
help="voice for TTS. Default: en-US-AriaNeural",
default="en-US-AriaNeural",
)
group.add_argument(
"-l",
"--list-voices",
help="lists available voices",
help="lists available voices and exits",
action="store_true",
)
parser.add_argument(
"-r",
"--rate",
help="set TTS rate. Default +0%%. For more info check https://bit.ly/3eAE5Nx",
default="+0%",
)
parser.add_argument(
"-V",
"--volume",
help="set TTS volume. Default +0%%. For more info check https://bit.ly/3eAE5Nx",
default="+0%",
)
parser.add_argument("--rate", help="set TTS rate. Default +0%%.", default="+0%")
parser.add_argument("--volume", help="set TTS volume. Default +0%%.", default="+0%")
parser.add_argument(
"-O",
"--overlapping",
@ -116,18 +106,16 @@ async def _async_main() -> None:
await _print_voices(proxy=args.proxy)
sys.exit(0)
if args.text is not None or args.file is not None:
if args.file is not None:
# we need to use sys.stdin.read() because some devices
# like Windows and Termux don't have a /dev/stdin.
if args.file == "/dev/stdin":
# logger.debug("stdin detected, reading natively from stdin")
args.text = sys.stdin.read()
else:
# logger.debug("reading from %s" % args.file)
with open(args.file, "r", encoding="utf-8") as file:
args.text = file.read()
if args.file is not None:
# we need to use sys.stdin.read() because some devices
# like Windows and Termux don't have a /dev/stdin.
if args.file == "/dev/stdin":
args.text = sys.stdin.read()
else:
with open(args.file, "r", encoding="utf-8") as file:
args.text = file.read()
if args.text is not None:
await _run_tts(args)