gotev / android-speech

Android speech recognition and text to speech made easy
http://gotev.github.io/android-speech/
Apache License 2.0
486 stars 157 forks source link

Is there a way to read large amounts of text? #59

Closed padrecedano closed 2 years ago

padrecedano commented 2 years ago

Thanks for this code.

I have tried reading a single text and it works, but I am interested in reading a lot of text. I have chunked the content so it doesn't exceed the maximum number of characters allowed. But reading doesn't work.

This is mi code:

        Speech speaker=Speech.getInstance();
        String[] textParts = mText.split(SEPARATOR);

        for (String s : textParts) {
            speaker.say(s,this);
        }

And I have this error:

W/TextToSpeech: Synthesis request paramter streamType containst value with invalid type. Should be an Integer or a Long

Is there a way to read large amounts of text?

gotev commented 2 years ago

Hi 😊 Glad the library is useful 🎉

Your intuition is correct. To read a large text, you need to chunk it into pieces.

Next step is to make a queue in which to put them and use the say method with the TextToSpeech delegate. When a chunk is completed, say the next one until there are no more chunks to say.