Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to get currently displayed page text from ePub #27

Closed
elraito opened this issue Feb 7, 2023 · 7 comments
Closed

Add ability to get currently displayed page text from ePub #27

elraito opened this issue Feb 7, 2023 · 7 comments

Comments

@elraito
Copy link

elraito commented Feb 7, 2023

Please add a method to to get text from currently displayed page.

Whats would this enable:

It would be helpful to implement accessibility options i.e. text-to-speech implementations.
Or ability to get a copy of text if the ePub might be educational for example.
Ability to create implementation for citations.
etc....

Personally i would love if it was in one of two formats:
a) A method accessible through ref you can manually call.
b) A callback that is fired on page change.

I personally favor option a but this is only an opinion.

@mickael-menu
Copy link

What are the use cases for the text of the currently displayed page instead of the whole text of the publication or current chapter?

@elraito
Copy link
Author

elraito commented Feb 7, 2023

For example grabbing displayed text for synthezizing voice for people with visual impairment through another library without synthezizing whole chapter. Implementing custom translation etc.

@mickael-menu
Copy link

TTS is supported in Readium, and can start from the current page. It's not available yet in the React native package though.

For the translation, you can get the text of a user selection and translate it. Translating the current page but not the full chapter would be complicated, and I don't really see the use case.

@elraito
Copy link
Author

elraito commented Feb 7, 2023

What languages does readium support for tts when it gets implemented in react native? Can it be customized? Will it parse language specific characters? All these questions can have an answer if the developer has access to implement custom tts. Not all books have chapters short enough for reasonable tts synthezizing in one batch and user selection is not always reliable or user friendly. Sadly o dont speak java or swift to open a pull request myself

@jspizziri
Copy link
Contributor

@elraito IIRC readium's TTS support relies on the underlying OS's TTS functionality. Therefore anything available there would be available in Readium.

@mickael-menu correct me if I'm wrong.

@jspizziri
Copy link
Contributor

@elraito I'm going to close this issue in favor of the preexisting TTS issue. #24

@mickael-menu
Copy link

The TTS in Readium is made of several independent components:

  1. A Content Iterator API which is used to extract the text (and more) from a publication. This is useful for TTS but also other use cases like search or to reformat the content in a custom view (accessibility reader).
  2. A Decorator API which is used to draw decorations on the pages. This is used to highlight the speaking sentences in the context of TTS.
  3. The TTS engine itself, that speaks utterances (sentences). You can provide your own TTS engine for full customization, but Readium provides a default implementation using the native TTS APIs on each platform, which support many languages. Users can add more languages from the system settings.
  4. And finally an orchestrator (TTS Navigator) which combines the other components to play the TTS across the whole publication and synchronize it with the EPUB navigator.

Not all books have chapters short enough for reasonable tts synthezizing in one batch and user selection is not always reliable or user friendly.

Sentences are never synthesized by the TTS engine in one batch. Utterances are computed lazily for a whole chapter, but synthesized/spoken one by one when needed.

I'm asking all these questions to see if something is missing in the core Readium API. In any case you should be able to inject your own JavaScript for unusual use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants