Unified aedocw backends

This commit is contained in:
2026-08-07 00:03:19 -03:00
parent da8940bdd4
commit b1c7a42172
12 changed files with 169 additions and 397 deletions
+19 -6
View File
@@ -23,7 +23,9 @@ optional arguments:
-b {default,edge,epub2tts,epub2tts-edge,epub2tts-chatterbox,epub2tts-kokoro}, --backend {default,edge,epub2tts,epub2tts-edge,epub2tts-chatterbox,epub2tts-kokoro}
Backend to use for TTS
"""
import os
import sys
from pathlib import Path
from argparse import ArgumentParser
from . import tts_aedocw, tts_edge, tts_generic
@@ -39,6 +41,7 @@ backend = {
"epub2tts-edge": tts_aedocw.AedocwEpub2TTSEdge,
"epub2tts-chatterbox": tts_aedocw.AedocwChatterbox,
"epub2tts-kokoro": tts_aedocw.AedocwKokoro,
"generic-epub2tts": tts_aedocw.Epub2TTS
}
@@ -63,18 +66,28 @@ def main(args=None):
)
args = p.parse_args(args or sys.argv[1:])
print(
f"Converting {args.input} to {args.output} using voice "
f"{args.voice}, language {args.language}, "
f"backend {args.backend}, ..."
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)
)
input_path = Path(args.input).resolve()
if not input_path.exists():
raise FileNotFoundError(f"Input file {input_path} does not exist.")
output_path = Path(args.output).resolve()
if not output_path.parent.exists():
os.makedirs(output_path.parent, exist_ok=True)
backend_cls = backend[args.backend]
backend_instance = backend_cls(
backend_cmd=None,
language=args.language,
voice=args.voice,
)
backend_instance.run(args.input, args.output)
backend_instance.run(
input_path, output_path,
**vars(args),
)
if __name__ == "__main__":