What would you like to see?
I would like to request a feature where Alexandria can automatically parse text from images that serve as chapter headings/titles, using either a local OCR library (e.g., easyocr or tesseract) or a local Multimodal/Vision LLM (e.g., Qwen2-VL, Llama-3.2-Vision) if the user has one configured.
Steps to Reproduce / Test Case
I have generated a minimal, copyright-free sample EPUB that reproduces this exact structure:
sample_image_chapters.zip
EPUB Markup Structure
In this sample, the chapter files (chapter1.xhtml, chapter2.xhtml) contain:
<div class="title-container">
<!-- The chapter title is represented solely as an image -->
<img class="title-image" src="images/chapter1-title.png" alt="Chapter Title Image" />
</div>
The actual text rendered in the image is:
- For Chapter 1:
"Chapter I: The Awoken Princess"
- For Chapter 2:
"Chapter II: The Crimson Nocturne"
Currently, Alexandria imports this chapter structure but does not extract the text from the images, meaning the generated script does not contain the actual chapter names.
Proposed Solution
- Detection: During EPUB parsing, identify blocks or headings that contain an
<img> element but no accompanying text.
- Text Extraction (OCR/VLM):
- Option A (Lightweight OCR): Use a Python OCR library like
easyocr or pytesseract to extract text from the referenced image.
- Option B (VLM integration): If the backend has access to a vision-enabled model, send the image to the model with a prompt like: "Extract the text from this chapter title image exactly as written."
- Replacement: Inject the extracted text back into the internal parsed representation of the chapter title before sending it to the script generation phase.
Use case
Many light novels and manga-adjacent ebooks (especially those published by Yen Press, e.g., The Vexations of a Shut-In Vampire Princess) use stylized images (PNG/JPEG) instead of text for chapter titles.
When Alexandria parses these EPUBs:
- The parser misses the chapter title text entirely since it only sees an
<img> tag (often with blank or generic alt text like "image" or "Chapter Title Image").
- This leads to missing chapter boundaries or generic labels in the generated script and the final chaptered audio output (e.g., M4B files).
- The LLM script generator is deprived of the chapter name context, which can affect the flow of script generation.
Publisher with this pattern: Yen Press, J-Novel Club (on certain titles), Kadokawa.
Alternatives considered
Before script generation I could pre-process the epub files myself to strip out chapter title images and replace them with text.
After script generation I could manually search for the first text in each chapter and insert new lines that include the chapter titles, for example by copy pasting from the TOC to each appropriate chapter title placement.
What would you like to see?
I would like to request a feature where Alexandria can automatically parse text from images that serve as chapter headings/titles, using either a local OCR library (e.g.,
easyocrortesseract) or a local Multimodal/Vision LLM (e.g.,Qwen2-VL,Llama-3.2-Vision) if the user has one configured.Steps to Reproduce / Test Case
I have generated a minimal, copyright-free sample EPUB that reproduces this exact structure:
sample_image_chapters.zip
EPUB Markup Structure
In this sample, the chapter files (
chapter1.xhtml,chapter2.xhtml) contain:The actual text rendered in the image is:
"Chapter I: The Awoken Princess""Chapter II: The Crimson Nocturne"Currently, Alexandria imports this chapter structure but does not extract the text from the images, meaning the generated script does not contain the actual chapter names.
Proposed Solution
<img>element but no accompanying text.easyocrorpytesseractto extract text from the referenced image.Use case
Many light novels and manga-adjacent ebooks (especially those published by Yen Press, e.g., The Vexations of a Shut-In Vampire Princess) use stylized images (PNG/JPEG) instead of text for chapter titles.
When Alexandria parses these EPUBs:
<img>tag (often with blank or genericalttext like"image"or"Chapter Title Image").Publisher with this pattern: Yen Press, J-Novel Club (on certain titles), Kadokawa.
Alternatives considered
Before script generation I could pre-process the epub files myself to strip out chapter title images and replace them with text.
After script generation I could manually search for the first text in each chapter and insert new lines that include the chapter titles, for example by copy pasting from the TOC to each appropriate chapter title placement.