This commit is contained in:
2026-08-06 18:20:54 -03:00
parent a2adafe9e8
commit f2c66a1876
9 changed files with 39 additions and 12 deletions
+25 -6
View File
@@ -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,
}
@@ -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):
+2 -1
View File
@@ -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):
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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.
+1
View File
@@ -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