LibreraReader icon indicating copy to clipboard operation
LibreraReader copied to clipboard

Highlight sentence being read by TTS

Open shadyabhi opened this issue 11 months ago • 5 comments

The benefit is that it helps keep the eyes focused on what's being read.

shadyabhi avatar Dec 29 '24 17:12 shadyabhi

I am planning to do this work, but I have no write permission now. I have a [Pull requests] waiting for merge now

testwind avatar Jan 01 '25 03:01 testwind

Hi @testwind , it is great that you are planning to do this work, because sentence highlighting will be a very useful feature. How is it going for you with getting the write permissions?

Hromakov avatar Jan 14 '25 18:01 Hromakov

I have made TTS sentence high light function for another Reader App.

  1. Split paragraph to sentences by punctuation mark.
  2. High light the split sentence.
  3. Auto turn page during TTS reading.
  4. Auto scroll page during TTS reading in horizontal mode. Keep high light sentence in the 2/5 middle of screen.

I am not contributor of this project, so I can not push commit, I have one pull request waiting for merge. The waiting time for a merge is too long. Can you give me permission to push commit ? @Hromakov

testwind avatar Jan 15 '25 06:01 testwind

@testwind , I am also not the contributor of this project, so cannot give you this permission. Wrote an email to the project administrators asking them to provide you with the write access.

FYI @foobnix

Hromakov avatar Jan 15 '25 10:01 Hromakov

@testwind , can you share the link to the pull request with sentence highlighting feature?

Hromakov avatar Jan 15 '25 10:01 Hromakov

You can also create a fork if it takes to long and upstream your changes.

Foobnix is currently busy with the war in ukraine, so he wont be available for a while.

DeanLemans avatar Mar 15 '25 13:03 DeanLemans

@testwind @DeanLemans @Hromakov

one general question.

when using "Librera Reader" source code , I need the current chapter text needs to preprocessed by sending to an API and show the output from API instead.

The API:

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GEMINI_API_KEY" \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
      "contents": [{
        "parts":[{"text": "translate to Tamil. Return the story only"}]
        }]
       }' 2> /dev/null

Is that possible ?

RageshAntonyHM avatar Mar 20 '25 16:03 RageshAntonyHM

@RageshAntonyHm I think you have two methods ,

  1. translate the whole book , epub file, and read the new book. Epub is just html , you can translate the content.
  2. translate some sentences during reading time: LibreraReader can long press some word and popup a window for http translate

testwind avatar Mar 21 '25 03:03 testwind

Hi @testwind , I would like to add the text highlighting during text-to-speech, but it seems to be complex. I have to use UtteranceProgressListener and somehow access the text contents as they are read. If you have an idea of possible solutions, could you please let me know?

Hromakov avatar Mar 25 '25 17:03 Hromakov

@Hromakov

  1. Every page are PDF images. You can get the content strings of each page, and the string character’s position.
  2. Split one paragraph’s sentence by chars [,.;?!], and get a sentence list.
  3. Sent the list to TTS, and start speak
  4. When a sentence is played, you can receive a “STOP” and next new “START”.
  5. Check your sentence list to find the current character’s position. Top-left , bottom-right
  6. Draw a transparent color rectangle of the current sentence.
  7. Some long sentence has multi-lines, you should draw more than one rectangle.
  8. Also should check the sentence in two page.
  9. Clear the previous highlight before draw the new highlight.
  10. The page should be able to scroll automatically. Some you should change the current page’s position by calculate the reading sentence.

testwind avatar Mar 26 '25 02:03 testwind

Hi @testwind , Thank you!

Hromakov avatar Apr 20 '25 16:04 Hromakov

I am planning to do this work, but I have no write permission now. I have a [Pull requests] waiting for merge now

Hey, have you done this change possibly for your fork of this project? Tried to understand the changes in your commits there but I just got lost. Then lost a few hours trying to build it, but didn't see a highlight option in the tts settings.

WizaHX avatar Apr 27 '25 18:04 WizaHX