From 52104b30b923a2fee6ed9ba829e3f62f615e6a99 Mon Sep 17 00:00:00 2001 From: Audiobook Producer Date: Sun, 18 Oct 2026 01:53:13 -0500 Subject: [PATCH] Install ghostscript fonts (urw-base35) for OCR of PDFs with non-embedded fonts; fuller OCR error text --- _pipeline/Dockerfile | 2 +- _pipeline/ci/install.sh | 2 +- _pipeline/ingest.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_pipeline/Dockerfile b/_pipeline/Dockerfile index b1dee9a..e98519f 100644 --- a/_pipeline/Dockerfile +++ b/_pipeline/Dockerfile @@ -4,7 +4,7 @@ FROM python:3.13-slim RUN apt-get update \ - && apt-get install -y --no-install-recommends ffmpeg poppler-utils tesseract-ocr tesseract-ocr-eng ocrmypdf ghostscript \ + && apt-get install -y --no-install-recommends ffmpeg poppler-utils tesseract-ocr tesseract-ocr-eng ocrmypdf ghostscript fonts-urw-base35 \ && rm -rf /var/lib/apt/lists/* COPY _pipeline/requirements.txt /tmp/requirements.txt diff --git a/_pipeline/ci/install.sh b/_pipeline/ci/install.sh index ddab8ba..66362e6 100755 --- a/_pipeline/ci/install.sh +++ b/_pipeline/ci/install.sh @@ -3,7 +3,7 @@ set -euo pipefail export DEBIAN_FRONTEND=noninteractive apt-get update -qq -apt-get install -y -qq --no-install-recommends ffmpeg poppler-utils tesseract-ocr tesseract-ocr-eng ocrmypdf ghostscript \ +apt-get install -y -qq --no-install-recommends ffmpeg poppler-utils tesseract-ocr tesseract-ocr-eng ocrmypdf ghostscript fonts-urw-base35 \ python3 python3-venv python3-pip git curl ca-certificates python3 -m venv .venv .venv/bin/pip install -q --disable-pip-version-check -r _pipeline/requirements.txt diff --git a/_pipeline/ingest.py b/_pipeline/ingest.py index 3f11f23..9489990 100644 --- a/_pipeline/ingest.py +++ b/_pipeline/ingest.py @@ -108,5 +108,5 @@ def ocr_if_needed(cfg, book_dir, book): src = os.path.join(book_dir, book["source_pdf"]) r = subprocess.run(["ocrmypdf", "--skip-text", "-l", cfg["ocr"]["language"], src, out], capture_output=True, text=True) if r.returncode != 0: - return [("ocr-failed", where, "ocrmypdf exit %d: %s" % (r.returncode, r.stderr.strip()[-300:]))] + return [("ocr-failed", where, "ocrmypdf exit %d: %s" % (r.returncode, (r.stderr.strip()[:300] + " ... " + r.stderr.strip()[-300:]) if len(r.stderr) > 650 else r.stderr.strip()))] return [("ocr", where, "OCR applied to a scratch copy; original untouched")]