Android TTS fails to speak large amount of text

后端 未结 5 1398
没有蜡笔的小新
没有蜡笔的小新 2021-01-02 05:01

I am trying to speak out large amount of text using Android Text To Speech. I using default Google speech engine. Below is my code.

 public class Talk extend         


        
5条回答
  •  清歌不尽
    2021-01-02 05:34

    In case someone might find this helpful. When you split the large text into strings, do not set the length of each string to the exact value of getMaxSpeechInputLength(). Subtract the string length by 1. Otherwise, only the last chunk of string could be read by TTS.

    int length = toSpeech.getMaxSpeechInputLength() - 1;
    Iterable chunks = Splitter.fixedLength(length).split(largeText);
    Lists.newArrayList(chunks);
    

提交回复
热议问题