From f2c66a1876b00aa04b55247fc6c0182abbb94e52 Mon Sep 17 00:00:00 2001 From: RenatoXSR Date: Thu, 6 Aug 2026 18:20:54 -0300 Subject: [PATCH] ... --- src/epub_tts/__main__.py | 31 +++++++++++++++---- .../{aedocw_backend.py => tts_aedocw.py} | 11 ++++--- src/epub_tts/tts_edge.py | 3 +- src/epub_tts/{epub2tts.py => tts_epub2tts.py} | 1 + ...atterbox.py => tts_epub2tts_chatterbox.py} | 1 + ...{epub2tts_edge.py => tts_epub2tts_edge.py} | 1 + ...b2tts_kokoro.py => tts_epub2tts_kokoro.py} | 1 + .../{tts_backend.py => tts_generic.py} | 1 + src/epub_tts/vendor_utils.py | 1 + 9 files changed, 39 insertions(+), 12 deletions(-) rename src/epub_tts/{aedocw_backend.py => tts_aedocw.py} (92%) rename src/epub_tts/{epub2tts.py => tts_epub2tts.py} (96%) rename src/epub_tts/{epub2tts_chatterbox.py => tts_epub2tts_chatterbox.py} (96%) rename src/epub_tts/{epub2tts_edge.py => tts_epub2tts_edge.py} (95%) rename src/epub_tts/{epub2tts_kokoro.py => tts_epub2tts_kokoro.py} (95%) rename src/epub_tts/{tts_backend.py => tts_generic.py} (97%) diff --git a/src/epub_tts/__main__.py b/src/epub_tts/__main__.py index ba51ce5..4959c86 100644 --- a/src/epub_tts/__main__.py +++ b/src/epub_tts/__main__.py @@ -1,25 +1,44 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) +"""Command-line interface for converting EPUB to audio using TTS. +This module provides a command-line interface (CLI) for converting EPUB files to audio using text-to-speech (TTS) backends. It allows users to specify the input EPUB file, output audio file, language, voice, and backend to use for TTS conversion. +usage: epub-tts [-h] [--version] -i INPUT -o OUTPUT [-l LANGUAGE] + [-v VOICE] [-b {default,edge,epub2tts,epub2tts-edge,epub2tts-chatterbox,epub2tts-kokoro}] + +optional arguments: + -h, --help show this help message and exit + --version Show version and exit + -i INPUT, --input INPUT + Input EPUB file + -o OUTPUT, --output OUTPUT + Output audio file + -l LANGUAGE, --language LANGUAGE + Language to use for TTS + -v VOICE, --voice Voice to use for TTS + -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 sys from argparse import ArgumentParser -from epub_tts import aedocw_backend, tts_backend, tts_edge +from . import tts_aedocw, tts_edge, tts_generic backend = { # keys are the backend names, values are the corresponding TTS classes - "default": tts_backend.GenericTTSBackend, + "default": tts_generic.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, + "epub2tts": tts_aedocw.AedocwEpub2TTS, + "epub2tts-edge": tts_aedocw.AedocwEpub2TTSEdge, + "epub2tts-chatterbox": tts_aedocw.AedocwChatterbox, + "epub2tts-kokoro": tts_aedocw.AedocwKokoro, } diff --git a/src/epub_tts/aedocw_backend.py b/src/epub_tts/tts_aedocw.py similarity index 92% rename from src/epub_tts/aedocw_backend.py rename to src/epub_tts/tts_aedocw.py index 4be64b3..6f2d8f2 100644 --- a/src/epub_tts/aedocw_backend.py +++ b/src/epub_tts/tts_aedocw.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) """Backends for the aedocw collection of EPUB->TTS repositories. @@ -14,11 +15,11 @@ corresponding console script is not available in the current environment. from typing import Optional -from . import epub2tts as epub2tts_adapter -from . import epub2tts_chatterbox as epub2tts_chatterbox_adapter -from . import epub2tts_edge as epub2tts_edge_adapter -from . import epub2tts_kokoro as epub2tts_kokoro_adapter -from .tts_backend import GenericTTSBackend +from . import tts_epub2tts as epub2tts_adapter +from . import tts_epub2tts_chatterbox as epub2tts_chatterbox_adapter +from . import tts_epub2tts_edge as epub2tts_edge_adapter +from . import tts_epub2tts_kokoro as epub2tts_kokoro_adapter +from .tts_generic import GenericTTSBackend class AedocwBackend(GenericTTSBackend): diff --git a/src/epub_tts/tts_edge.py b/src/epub_tts/tts_edge.py index 45d6a31..c624b66 100644 --- a/src/epub_tts/tts_edge.py +++ b/src/epub_tts/tts_edge.py @@ -2,9 +2,10 @@ # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> """Compatibility shim for the edge backend in epub-tts.""" -from .aedocw_backend import AedocwEpub2TTSEdge +from .tts_aedocw import AedocwEpub2TTSEdge class TTSEdge(AedocwEpub2TTSEdge): diff --git a/src/epub_tts/epub2tts.py b/src/epub_tts/tts_epub2tts.py similarity index 96% rename from src/epub_tts/epub2tts.py rename to src/epub_tts/tts_epub2tts.py index 8996d57..ad538ca 100644 --- a/src/epub_tts/epub2tts.py +++ b/src/epub_tts/tts_epub2tts.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> """Adapter for the vendored github.com/aedocw/epub2tts repository.""" import subprocess diff --git a/src/epub_tts/epub2tts_chatterbox.py b/src/epub_tts/tts_epub2tts_chatterbox.py similarity index 96% rename from src/epub_tts/epub2tts_chatterbox.py rename to src/epub_tts/tts_epub2tts_chatterbox.py index 8ecfc04..40d7f27 100644 --- a/src/epub_tts/epub2tts_chatterbox.py +++ b/src/epub_tts/tts_epub2tts_chatterbox.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> """Adapter for the vendored github.com/aedocw/epub2tts-chatterbox repository.""" import subprocess diff --git a/src/epub_tts/epub2tts_edge.py b/src/epub_tts/tts_epub2tts_edge.py similarity index 95% rename from src/epub_tts/epub2tts_edge.py rename to src/epub_tts/tts_epub2tts_edge.py index ef4ae18..e3dbcfb 100644 --- a/src/epub_tts/epub2tts_edge.py +++ b/src/epub_tts/tts_epub2tts_edge.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> """Adapter for the vendored github.com/aedocw/epub2tts-edge repository.""" import subprocess diff --git a/src/epub_tts/epub2tts_kokoro.py b/src/epub_tts/tts_epub2tts_kokoro.py similarity index 95% rename from src/epub_tts/epub2tts_kokoro.py rename to src/epub_tts/tts_epub2tts_kokoro.py index 5099cd9..c16391c 100644 --- a/src/epub_tts/epub2tts_kokoro.py +++ b/src/epub_tts/tts_epub2tts_kokoro.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> """Adapter for the vendored github.com/aedocw/epub2tts-kokoro repository.""" import subprocess diff --git a/src/epub_tts/tts_backend.py b/src/epub_tts/tts_generic.py similarity index 97% rename from src/epub_tts/tts_backend.py rename to src/epub_tts/tts_generic.py index 50c4c05..9c7d48a 100644 --- a/src/epub_tts/tts_backend.py +++ b/src/epub_tts/tts_generic.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> """Generic TTS Backend for handling text-to-speech conversion. This module provides a generic TTS backend that can be used to convert text to speech using various TTS engines. It defines a `GenericTTSBackend` class that can be initialized with a specific backend command, language, and voice. The class provides methods to normalize paths, determine input and output flags based on the type of input/output (file or directory), build the command for the TTS engine, and run the command. diff --git a/src/epub_tts/vendor_utils.py b/src/epub_tts/vendor_utils.py index 9ab2d73..2fa3d10 100644 --- a/src/epub_tts/vendor_utils.py +++ b/src/epub_tts/vendor_utils.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (c) 2025-2026 Renato Xavier da Silveira Rosa # See [LICENSE](./LICENSE) or [BSD-3-Clause-Clear](https://spdx.org/licenses/BSD-3-Clause-Clear.html) +# Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> """Utilities for running vendored EPUB->TTS repositories in isolated venvs.""" import subprocess