Skip to content

Modernize installation and audiobook generation - #17

Merged
mateogon merged 11 commits into
mainfrom
codex/renovacion-local
Oct 25, 2026
Merged

mateogon merged 11 commits into
mainfrom
codex/renovacion-local

Conversation

@mateogon

@mateogon mateogon commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fresh installations currently depend on unused DeepSpeed, Java/Tika and Qt packages, and chapter generation accumulates the entire waveform in memory. This change replaces the platform freezes with one pyproject.toml and uv.lock, streams audio to an atomic output file, and shares CPU/CUDA/MPS selection between the CLI and desktop app.

  • Install and launch with uv run pdf-narrator; no separate DeepSpeed, Java, Qt or eSpeak NG installation is required. Kokoro uses the bundled eSpeak library.
  • Resume only when source, settings and output hashes match. Reject invalid/empty generated chunks and preserve previous audio on failure or cancellation.
  • Add a CLI and M4B export with chapter titles, EPUB metadata and cover artwork. M4B intermediates remain in OUTPUT_DIR/chapters/ for verified resume.
  • Preserve current extracted chapters and real titles in a manifest; ignore stale chapters without deleting user files. Fix EPUB NCX title parsing.
  • Add chapter review/edit/exclusion and sample playback. Route worker updates through a queue consumed by Tk's main thread; the Mac crash during preparation no longer reproduces in the verified flow.

Install

Install uv, clone this branch, and run from the repository:

Platform Command
macOS uv run --locked pdf-narrator (MPS selected when available)
Windows / Linux CPU uv run --locked pdf-narrator
Windows / Linux NVIDIA uv run --locked --no-default-groups --extra cuda pdf-narrator

Keep the CUDA flags on subsequent uv run commands. The project selects Python 3.12. M4B needs FFmpeg on PATH. OCR additionally needs --extra ocr, Tesseract and Poppler; ordinary text extraction does not need these tools. No drivers or system software were changed on the Windows test laptop.

Example: uv run --locked pdf-narrator book.epub --voice ef_dora --format m4b --resume.

Evidence

Platform / device Validation English synthesis speed
Apple Silicon CPU Real Kokoro synthesis; installed CLI and M4B; local suite and GUI flow 5.71×
Apple Silicon MPS Real synthesis; preparation → review/edit → generation; sample playback 15.63×
Windows 11 CPU 102 passed, 1 optional-OCR skip, 12 subtests; TXT → M4B; full decode 3.57×
Windows 11 RTX 3050 CUDA Same suite; TXT → M4B; full decode 28.44×
Ubuntu / Windows / macOS CI Each: 102 passed, 2 optional-OCR skips, 12 subtests; native Tk and FFmpeg Not benchmarked

Three-platform CI run: all three platforms passed. CI runs with Hugging Face offline and does not download Kokoro weights. The separate Ubuntu job also passed real OCR on an image-only synthetic PDF (1 passed, Tesseract 5.3.4).

Windows used Python 3.12.12, uv 0.9.26, existing FFmpeg and driver 592.82: Torch 2.14.1+cpu and 2.11.0+cu128 in separate environments. CPU/CUDA synthesized 123.325 seconds of audio in 34.502/4.337 seconds; model load took 2.565/2.761 seconds. CUDA peaked at 994 MiB allocated and 1634 MiB reserved by PyTorch, below the laptop's 6 GiB. These counters exclude other processes and driver memory.

Single measurements, not a statistical study. Windows used the production CLI's extraction/cleaning with the same source text; Mac used the direct engine benchmark and produced 119.3 seconds. The speeds are not an identical-pipeline hardware comparison. Java and eSpeak were present on Windows; an isolated process succeeded without them on PATH and confirmed use of the bundled eSpeak DLL. DeepSpeed and Tika were absent from both app environments.

Writer memory

Same synthetic 20-minute waveform, separate processes, no TTS model:

Writer Peak process RSS Write time
Original 866.0 MiB 0.177 s
Streaming 316.6 MiB 0.450 s

Observed peak RSS fell about 63%, with more disk operations. This is a writer regression measurement, not a full-book memory guarantee.

Audio behavior changes: the writer clips each chunk and preserves Kokoro's amplitude instead of normalizing the whole chapter to its peak. Listening and the engine choice remain separate review decisions; this PR keeps Kokoro/Torch.

Related work

Addresses #1, #3, #8, #11, #12, #13.

This replaces the platform-specific dependency approach in #15. It incorporates the punctuation-only static safeguard identified by @Puddings22 in #16, without importing that PR's unrelated Linux requirements freeze. Neither existing PR nor any issue is closed by this change.

Not verified

  • Visual interaction with the Windows desktop: the real Tk app opened over SSH and its CUDA control was enabled, but the desktop was not visually reviewed.
  • Ubuntu 4K scaling, Arch-specific runtime behavior, a complete long book, or the original reporter's book/hardware from Dies in middle of generation #12.
  • Subjective narration quality and final acceptance of the changed volume policy. Synthetic OCR coverage does not establish accuracy on arbitrary scanned books.

Follow-ups

  • Split TXT files heuristically at chapter headings; TXT currently remains one chapter.
  • Optionally remove punctuation-only lines during extraction; synthesis already filters them.
  • Evaluate a possible ONNX switch separately after listening to the existing samples.

🤖 Generated with Codex

mateogon and others added 11 commits October 25, 2026 12:05
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant