Build read aloud chunks from the text selection OCR instead of a separate request - #1602
Merged
Merged
Conversation
…rate request Co-Authored-By: Drini Cami <cdrini@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1602 +/- ##
==========================================
+ Coverage 63.84% 64.11% +0.27%
==========================================
Files 69 69
Lines 6253 6290 +37
Branches 1386 1398 +12
==========================================
+ Hits 3992 4033 +41
+ Misses 2222 2218 -4
Partials 39 39 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Drini Cami <cdrini@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cdrini
commented
Sep 30, 2026
| * @param {Element} ocrPage djvu xml `OBJECT` element | ||
| * @return {Array<[String, ...DJVURect[]]>} | ||
| */ | ||
| static _chunkOcrPage(ocrPage) { |
Contributor
Author
There was a problem hiding this comment.
This is a JS translation of the python code. Having this code here means we can make a number of improvements to how this works much more easily!
bfalling
reviewed
Sep 30, 2026
bfalling
approved these changes
Sep 30, 2026
bfalling
left a comment
Contributor
There was a problem hiding this comment.
LGTM (one suggestion re: ===
Co-Authored-By: Drini Cami <cdrini@gmail.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature/refactor. Read aloud used to request each page's text a second time from
BookReaderGetTextWrapper.php(paragraphs mode), even though the text selection plugin had already fetched the same page's djvu xml.PageChunk.fetchnow builds its chunks from the text selection plugin's OCR (getPageText), and only falls back to the page chunk URL when that plugin is missing or disabled, has no OCR for the page, or fails to load it.Technical
PageChunk._chunkOcrPageis a JS port of the server'sextract_paragraphs. A chunk ends at the first word ending in "." once it has more than 25 words, or at the end of a line once it has more than 50. It returns one rect per line, or per part of a line when a chunk ends mid-line, and skips header/footer paragraphs (x-role). We likely want to tweak/improve some of this logic.[text, ...rects]shape as the endpoint, so_fromTextWrapperResponse(hyphen removal, rect fixing) still applies unchanged.right=maxsize, top=-1. That's the "ridiculously wide first rect"_fixChunkRectsworks around. The JS port doesn't have this bug.Testing
_chunkOcrPageand thefetchfallbacks.adventureofsherl0000unse(most with headers/footers): the text was identical, and the rects were identical except the ones the server corrupts as described above.BookReaderGetTextWrapper.phprequests withoutmode=djvu_xml, and that highlighting and page turning still follow along.Screenshots/Videos
N/A, no visual change.
🤖 Generated with Claude Code