aboutsummaryrefslogtreecommitdiff
path: root/audiobook.py
diff options
context:
space:
mode:
Diffstat (limited to 'audiobook.py')
-rwxr-xr-xaudiobook.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/audiobook.py b/audiobook.py
index 792b274..6c075ea 100755
--- a/audiobook.py
+++ b/audiobook.py
@@ -5,12 +5,13 @@ Converts TXT, PDF and EPUB files into audiobooks using a local TTS server.
Run with no arguments in a terminal for the full TUI (set up backends,
process the input directory); pass flags to script a conversion directly.
-Edit converter/config.py to change voice and processing settings.
+Edit app/converter/config.py to change voice and processing settings.
"""
import argparse
import sys
import traceback
+from pathlib import Path
# Fix Windows console encoding for unicode output
if sys.platform == "win32":
@@ -20,6 +21,12 @@ if sys.platform == "win32":
except AttributeError:
pass
+# Everything non-user-facing (source packages, generated dirs, venv, backend
+# checkouts) lives under ./app so the checkout root stays clean. Put it on
+# sys.path before importing the packages below.
+APP_DIR = Path(__file__).resolve().parent / "app"
+sys.path.insert(0, str(APP_DIR))
+
# The managed-environment bootstrap (backends.envs) is stdlib-only and is
# imported here so main() can launch it before any third-party dependency is
# touched. It must NOT run at import time (importing this module must stay
@@ -174,7 +181,7 @@ Examples:
"With --backend audiocpp the language is adapted to the model "
"family: sent as a code (e.g. 'en') for families that take one, or "
"omitted when the model detects the language itself. Defaults to "
- "the LANGUAGE setting in converter/config.py (English).")
+ "the LANGUAGE setting in app/converter/config.py (English).")
)
parser.add_argument(
"--speed", type=float, default=1.0,
@@ -198,7 +205,7 @@ Examples:
"audio.cpp audiocpp_server (audiocpp) hosting any of its TTS "
"model families — Qwen3-TTS, Higgs Audio, VoxCPM2, IndexTTS2, "
"and more. Defaults to the BACKEND setting in "
- "converter/config.py (audiocpp).")
+ "app/converter/config.py (audiocpp).")
)
parser.add_argument(
"--voice", type=str, default=None, metavar="NAME",
@@ -207,7 +214,7 @@ Examples:
"with --ref-audio). audiocpp: a voice_preset or voice_dir entry "
"(cloning); required for audio.cpp families without built-in "
"speakers (everything except Qwen3-TTS CustomVoice). Not used by "
- "the qwen backend (use converter/config.py SPEAKER or --clone "
+ "the qwen backend (use app/converter/config.py SPEAKER or --clone "
"there).")
)
parser.add_argument(
@@ -219,7 +226,7 @@ Examples:
parser.add_argument(
"--chunk", action="store_true",
help=("Force client-side chunking into CHUNK_SIZE-word requests (see "
- "converter/config.py). Only matters for --backend audiocpp, which "
+ "app/converter/config.py). Only matters for --backend audiocpp, which "
"otherwise sends each chapter as one request and lets the server "
"chunk long text itself; the qwen and faster backends always "
"chunk.")
@@ -228,7 +235,7 @@ Examples:
"--model", type=str, default=None, metavar="ID",
help=("audio.cpp server model entry id to use for this run "
"(--backend audiocpp only). Overrides AUDIOCPP_MODEL_ID in "
- "converter/config.py, which is useful for a server hosting "
+ "app/converter/config.py, which is useful for a server hosting "
"several lazily-loaded models: generate one server.json with "
"backends.audiocpp, then pick the model per run with --model. "
"Leave unset to use the config id, or to auto-select when the "
@@ -243,7 +250,7 @@ Examples:
"'A warm adult female narrator with a British accent'. On "
"other families it acts as a style/delivery instruction when "
"the model supports one and is ignored otherwise. Defaults to "
- "AUDIOCPP_INSTRUCTIONS in converter/config.py (empty).")
+ "AUDIOCPP_INSTRUCTIONS in app/converter/config.py (empty).")
)
parser.add_argument(
"--option", action="append", type=str, default=None, metavar="KEY=VALUE",
@@ -306,7 +313,7 @@ Examples:
if args.voice is not None:
parser.error("--voice requires --backend faster or audiocpp; the "
"qwen backend uses built-in speakers "
- "(converter/config.py SPEAKER) or --clone")
+ "(app/converter/config.py SPEAKER) or --clone")
if args.language is not None:
try:
args.language = normalize_language(args.language)