mirror of
https://github.com/rany2/edge-tts
synced 2024-11-22 01:45:02 +00:00
Provide warning before writing binary to stdout
* Writing binary data to terminal could cause unintended behavior and mess up a terminal. Print a warning before doing such a thing.
This commit is contained in:
parent
4f70613c03
commit
6c55e815bb
@ -36,6 +36,21 @@ async def _print_voices(*, proxy: str) -> None:
|
||||
|
||||
async def _run_tts(args: Any) -> None:
|
||||
"""Run TTS after parsing arguments from command line."""
|
||||
|
||||
try:
|
||||
if sys.stdin.isatty() and sys.stdout.isatty() and not args.write_media:
|
||||
print(
|
||||
"Warning: TTS output will be written to the terminal. "
|
||||
"Use --write-media to write to a file.\n"
|
||||
"Press Ctrl+C to cancel the operation. "
|
||||
"Press Enter to continue.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
input()
|
||||
except KeyboardInterrupt:
|
||||
print("\nOperation canceled.", file=sys.stderr)
|
||||
return
|
||||
|
||||
tts: Communicate = Communicate(
|
||||
args.text,
|
||||
args.voice,
|
||||
|
Loading…
Reference in New Issue
Block a user