Kokoro working, updated interface

This commit is contained in:
2026-08-07 14:53:53 -03:00
parent 28ffc1820b
commit a1f564a051
7 changed files with 138 additions and 60 deletions
+20 -11
View File
@@ -28,7 +28,11 @@ import sys
from pathlib import Path
from argparse import ArgumentParser
from dotenv import load_dotenv
from . import tts_aedocw, tts_generic
from . import log, PathLike
load_dotenv() # load environment variables from .env file if present
backend = {
# keys are the backend names, values are the corresponding TTS classes
@@ -55,8 +59,12 @@ def main(args=None):
)
p.add_argument("-i", "--input", help="Input EPUB file", required=True)
p.add_argument("-o", "--output", help="Output audio file", required=True)
p.add_argument("-l", "--language", help="Language to use for TTS")
p.add_argument("-v", "--voice", help="Voice to use for TTS")
p.add_argument("-l", "--language", help="Language to use for TTS (see your backend's documentation for available voices)")
p.add_argument("-v", "--voice", help="Voice to use for TTS (see your backend's documentation for available voices)")
p.add_argument("--speed", type=float, default=1.0, help="Playback speed multiplier (default: 1.0) (not all backends support this)")
p.add_argument("--short-pause", type=int, default=None, help="Short pause duration in milliseconds between phrases or sentences (not all backends support this)")
p.add_argument("--long-pause", type=int, default=None, help="Long pause duration in milliseconds between sections or paragraphs (not all backends support this)")
p.add_argument("-c", "--cover", help="Path to cover image to embed or use for output metadata")
p.add_argument("-r", "--replace", action="append", nargs=2, help="Replace text in the intermediate output. Specify pairs of old_text new_text. Can be used multiple times.")
p.add_argument(
"-b",
@@ -68,18 +76,19 @@ def main(args=None):
args = p.parse_args(args or sys.argv[1:])
setattr(args, 'replace_map',
{old: new for old, new in args.replace} if args.replace else None)
print(
f"Converting {args.input} to {args.output} "
f"using {args.backend} backend "
"and args: " + ", ".join(
f"{k}={v}" for k, v in vars(args).items()
if k not in ("input", "output", "backend") and v is not None)
)
log(args)
# log(
# f"Converting {args.input} to {args.output} "
# f"using {args.backend} backend "
# "and args: " + ", ".join(
# f"{k}={v}" for k, v in vars(args).items()
# if k not in ("input", "output", "backend") and v is not None)
# )
#print(args.replace_map)
#log(args.replace_map)
backend[args.backend]().run(
backend[args.backend](**vars(args)).run(
args.input, args.output,
**vars(args),
)