[epub-tts] Vendor aedocw backends and add adapter subclasses
- Add git submodules under src/vendor for the aedocw repositories: - epub2tts, epub2tts-edge, epub2tts-chatterbox, epub2tts-kokoro - Add adapter modules in src/epub_tts to run vendored packages in isolated venvs: - vendor_utils.py (creates/uses per-repo .venv and installs package) - epub2tts.py, epub2tts_edge.py, epub2tts_chatterbox.py, epub2tts_kokoro.py - Add aedocw_backend.py providing AedocwBackend and concrete subclasses that dispatch to the vendored adapters when selected via the CLI. - Add tts_edge shim for backward compatibility. - Register new backends in src/epub_tts/__main__.py and invoke the selected backend at runtime. - Update pyproject.toml to exclude vendored packages from setuptools package discovery. This change vendors upstream tools while providing thin adapters that invoke their CLIs inside isolated virtualenvs, and integrates them into the epub-tts backend registry. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -7,13 +7,19 @@
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from epub_tts import tts_backend
|
||||
from epub_tts import tts_edge
|
||||
from epub_tts import aedocw_backend, tts_backend, tts_edge
|
||||
|
||||
backend = {
|
||||
# keys are the backend names, values are the corresponding TTS classes
|
||||
"default": tts_backend.GenericTTSBackend,
|
||||
"edge": tts_edge.TTSEdge,
|
||||
# aedocw-backed implementations — these expect the corresponding
|
||||
# package "console scripts"/entrypoints to be available in the
|
||||
# environment (or an explicit backend_cmd to be provided).
|
||||
"epub2tts": aedocw_backend.AedocwEpub2TTS,
|
||||
"epub2tts-edge": aedocw_backend.AedocwEpub2TTSEdge,
|
||||
"epub2tts-chatterbox": aedocw_backend.AedocwChatterbox,
|
||||
"epub2tts-kokoro": aedocw_backend.AedocwKokoro,
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +35,13 @@ def main(args=None):
|
||||
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("-b", "--backend",
|
||||
help="Backend to use for TTS",
|
||||
default="default",
|
||||
choices=backend.keys())
|
||||
p.add_argument(
|
||||
"-b",
|
||||
"--backend",
|
||||
help="Backend to use for TTS",
|
||||
default="default",
|
||||
choices=backend.keys(),
|
||||
)
|
||||
args = p.parse_args(args or sys.argv[1:])
|
||||
print(
|
||||
f"Converting {args.input} to {args.output} using voice "
|
||||
@@ -40,6 +49,14 @@ def main(args=None):
|
||||
f"backend {args.backend}, ..."
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
||||
Reference in New Issue
Block a user