From b6795046bf20023fd7b2e083ead20e7362f0c0d7 Mon Sep 17 00:00:00 2001 From: historia Date: Thu, 27 Aug 2026 18:41:10 -0400 Subject: feat: simply generate audiobooks menu, move more config to settings menu --- app/converter/config.py | 21 +++++++++++++++++++-- app/converter/converter.py | 19 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) (limited to 'app/converter') diff --git a/app/converter/config.py b/app/converter/config.py index 7424a76..9a07353 100644 --- a/app/converter/config.py +++ b/app/converter/config.py @@ -10,8 +10,25 @@ HEARTBEAT_INTERVAL_SECONDS = 30 # Print "still working" in console logs every N # Words per TTS generation request (client-side chunking). CHUNK_SIZE = 250 -# Default for "Stop server and exit" on the Generate Audiobooks form -# (TUI Settings menu: "Default stop server and exit"). +# Where books are read from and where finished audiobooks are written. +# Relative paths resolve against the project root (the folder containing +# audiobook.py). The --input/--output CLI flags override these per run. +INPUT_DIR = "./input" +OUTPUT_DIR = "./output" + +# Playback speed factor for the final audiobook (1.0 = normal). +# Pitch-preserving. The --speed CLI flag overrides this per run. +SPEED = 1.0 + +# Dump each chunk's raw audio and the exact text sent for it under the +# debug/ folder (organized per book and chapter), and log every TTS +# request and response to the console and log file. The --debug CLI flag +# forces this on for a single run. +DEBUG = False + +# Default for "Stop server and exit" (TUI Settings menu: "Stop server +# and exit"): automatically stop the TTS server and exit the TUI after +# generating audiobooks. STOP_SERVER_AND_EXIT = True # Default TTS backend. diff --git a/app/converter/converter.py b/app/converter/converter.py index b356448..d2d06b9 100644 --- a/app/converter/converter.py +++ b/app/converter/converter.py @@ -36,13 +36,26 @@ from .clients import ( logger = logging.getLogger(__name__) # Folders, resolved from the project root so the converter runs from any -# working directory. User-facing dirs (input/, output/) stay at the root; +# working directory. User-facing dirs (input/, output/) come from config +# (INPUT_DIR/OUTPUT_DIR; relative paths resolve against the project root); # scratch/log dirs live under the app/ container. BASE_DIR = Path(__file__).resolve().parent.parent.parent APP_DIR = BASE_DIR / "app" -BOOKS_FOLDER = BASE_DIR / "input" -AUDIOBOOKS_FOLDER = BASE_DIR / "output" + +def resolve_dir(value, default: str) -> Path: + """Resolve a configured directory VALUE (str/Path) to a Path. + + Blank values fall back to DEFAULT ("input"/"output"); relative + paths resolve against the project root so the converter runs from + any working directory, and "~" expands to the home directory. + """ + path = Path(str(value or "").strip() or default).expanduser() + return path if path.is_absolute() else BASE_DIR / path + + +BOOKS_FOLDER = resolve_dir(config.INPUT_DIR, "input") +AUDIOBOOKS_FOLDER = resolve_dir(config.OUTPUT_DIR, "output") CHUNKS_FOLDER = APP_DIR / "chunks" # Per-chunk scratch audio, cleaned per book LOGS_FOLDER = APP_DIR / "logs" DEBUG_FOLDER = APP_DIR / "debug" # --debug dumps, kept across runs -- cgit v1.2.3