Add Text-to-Speech support for PDF publications#668
Add Text-to-Speech support for PDF publications#668darktasevski wants to merge 5 commits intoreadium:developfrom
Conversation
This commit adds TTS (Text-to-Speech) functionality for PDF publications by integrating PDFKit-based text extraction capabilities. Changes: - Add PDFResourceContentIterator for extracting text content from PDFs - Intelligent paragraph detection using multiple strategies - Precise locator positioning with page and paragraph indices - Platform-specific implementation using PDFKit (iOS, macOS, Catalyst) - Update PDFParser to register ContentService with PDF text iterator - Enables automatic TTS support for PDFs with extractable text - Maintains backward compatibility with existing code The implementation is modular and follows the existing ContentIterator pattern used for EPUB publications, ensuring consistency across the toolkit.
|
Hi @darktasevski, thank you for contributing to the toolkit! This looks like a valuable addition. However, given the complexity, it would be best to split this into two separate PRs:
Would you mind starting with a new PR just for the PDF decorations? Regarding the code, I have a few initial questions:
|
|
@mickael-menu Thanks for the review and sorry for the delayed reply, it's a bit hectic with holidays and all. I'll try to break down the PR into two separate ones this week. Regarding questions, I wrote this a few months ago, so I can't remember the exact details. I think I'm using a paragraph index to keep track of the last TTS-read paragraph, but I'll need to confirm. Sentence-level segmentation sounds like a better option for TTS. Thanks for the suggestion, I'll see what I can do. |
|
No problem, I was also late in reviewing your PR. I'll try to be more responsive for the smaller ones. You can start with the Decorator when you have time, and we'll look at the Content Iterator later. Thank you! |
This PR adds TTS (Text-to-Speech) functionality for PDF publications by integrating PDFKit-based text extraction capabilities.
Changes:
Add PDFResourceContentIterator for extracting text content from PDFs
Update PDFParser to register ContentService with PDF text iterator
The implementation is modular and follows the existing ContentIterator pattern used for EPUB publications. I'm using this approach in my app, and it works without any issues (at least, none that I'm aware of).
CleanShot.2025-11-09.at.11.29.58.mp4