tts-voice-creator-clone-and.../routes
mARTin-B78 477cb43d4a feat: escalate magazine OCR to a connected vision engine on garbled/scanned pages
A page needing OCR (or whose already-extracted text -- native or
tesseract alike -- scores as mostly garbage via ocr_quality_score) is
now escalated to a connected vision OCR engine before falling back to
tesseract. Falls back automatically on any failure (unreachable engine,
timeout, unparseable output); never fatal to ingestion.

Verified live against ocr-baidu-unlimited-ocr on a real 28-page scanned
c't magazine excerpt (Epson ES-580W, no scanner OCR): every garbled
article title tesseract produced ("K | soll Arbeit abnehmen", ". |",
"@)X", "Owns mee") was replaced by the real headline ("1. Irrtum: KI
ist ein allgemeiner Jobkiller", etc.), and furniture detection jumped
from 44 to 151 blocks because the engine labels running headers/
footers/page numbers directly instead of needing fuzzy post-hoc
matching. 26 of 28 pages used the vision path; the remaining 2 fell
back to tesseract automatically.

Also fixes two real defects found investigating the same real-world
data, both regression-tested against the actual garbled strings
observed:
- Exact-match repeated-line detection (running header/footer) silently
  failed once tesseract OCR'd the same line differently each time --
  cluster_running_furniture fuzzy-matches near-edge blocks instead.
- ocr_page() built one Block per OCR text-LINE rather than per
  paragraph, so a single anomalous line (a chart number, scan noise, a
  wrapped headline continuation) could independently trigger title
  classification -- now grouped by paragraph like the native PyMuPDF
  path, using the paragraph's median line height rather than its total
  bbox height for font size.

A vision-engine label (footer/title/page_number/caption) is trusted
outright and skips classify_blocks' font-size heuristics entirely,
since the engine gives no reliable font metric; an ambiguous "text"
region gets a synthesized estimate from its paragraph area and length
(estimate_font_size_from_area) and still goes through normal
classification.

Off unless vision_ocr_url/vision_ocr_model are configured
(vision_ocr_enabled setting, default on if reachable); per-request
override via the ingest endpoint body. Default engine URL uses
host.docker.internal, confirmed live -- the OCR container runs on its
own Docker network, not dgx_net, so a container-name default would not
resolve from the app container.

28 new tests (136 total in the module). ocr_quality_score is
deliberately coarse and documented as such: it catches text that is
mostly symbol noise, not a plausible single-word misread inside an
otherwise normal sentence (confirmed live: a misread "KI" -> "K |"
still scored 0.81) -- that class of error needs a dictionary or
language-model check, out of scope here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-06 19:06:11 +02:00
..
__init__.py Security audit, modular refactor, and container-name field 2026-05-29 12:13:07 +02:00
admin.py Release v1.22.2 2026-09-03 16:12:02 +02:00
characters.py feat: validate canonical image asset digests 2026-09-04 09:53:50 +02:00
conversation.py test: lock visual identity prompts 2026-09-04 15:30:39 +02:00
docker.py feat: add OCR engine profiles 2026-09-04 22:29:11 +02:00
history.py feat: record protected generation history 2026-09-04 08:07:42 +02:00
jobs.py feat: expand resource diagnostics 2026-09-04 10:42:08 +02:00
library.py security: validate upload filenames and archive paths 2026-09-04 08:04:26 +02:00
magazine.py feat: escalate magazine OCR to a connected vision engine on garbled/scanned pages 2026-09-06 19:06:11 +02:00
reader.py Refine character sheets and live output UI 2026-07-09 19:47:16 +02:00
recovery.py security: harden P0 boundaries and recovery 2026-09-04 07:33:41 +02:00
rehearsals_db.py Release v1.22.3 2026-09-04 07:28:26 +02:00
settings.py fix: prevent caching of API key handoff 2026-09-04 08:52:46 +02:00
sources.py perf: bound fish audio response cache 2026-09-04 07:53:17 +02:00
stt.py feat: distinguish provider configuration and health 2026-09-04 11:35:52 +02:00
tts.py feat: distinguish provider configuration and health 2026-09-04 11:35:52 +02:00