Add 'process': one command for a whole book (all chapters), idempotent, loud failures, OCR required; synthetic test-PDF tool

This commit is contained in:
Audiobook Producer
2026-10-18 01:34:58 -05:00
parent 460d4648cb
commit 8c9ea14568
6 changed files with 656 additions and 2 deletions
+13
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
"""One command line for the whole pipeline.
python3 _pipeline/cli.py process <pdf> [--dry-run] [--force] EVERYTHING for a whole book, all chapters; exit 1 on any failure
python3 _pipeline/cli.py run <pdf> --chapters 1 ingest, structure, cleanup, figures, script, license
python3 _pipeline/cli.py ingest|structure|cleanup|figures|script|license ...
python3 _pipeline/cli.py voice <book_dir> [--only NAME] script segments -> wav pieces (needs the voice endpoint)
@@ -61,6 +62,15 @@ def main(argv=None):
p.add_argument("--chapters", required=True, type=chapters_arg, help="chapter numbers, e.g. 1 or 1,2")
p.add_argument("--title")
p.add_argument("--author")
p = sub.add_parser("process", help="whole book, all stages, all chapters")
p.add_argument("pdf")
p.add_argument("--dry-run", action="store_true", help="text stages only; checks the voice server is reachable; renders nothing")
p.add_argument("--force", action="store_true", help="re-render audio even if it exists")
p.add_argument("--title")
p.add_argument("--author")
p.add_argument("--compare", help="a books folder (like the repo books/); the text-stage output is compared with the same <author>/<book> folder in it")
p.add_argument("--compare-strict", action="store_true", help="with --compare: fail when the output differs (default: report only)")
p.add_argument("--result-file", help="write {ok, book_dir, pdf} JSON here")
p = sub.add_parser("ingest")
p.add_argument("pdf")
p.add_argument("--title")
@@ -82,6 +92,9 @@ def main(argv=None):
a = ap.parse_args(argv)
cfg = settings.load(a.settings)
if a.cmd == "process":
import process
sys.exit(process.process(cfg, a.pdf, a.dry_run, a.force, a.title, a.author, a.compare, a.result_file, a.compare_strict))
if a.cmd in ("run", "ingest"):
book_dir = ingest.run(cfg, os.path.abspath(a.pdf), a.title, a.author)
print("ingest done ->", book_dir)