Text to speech, show read words

岁酱吖の 提交于 2020-01-06 03:16:07

问题


I am working on an android application to read text, but I need to display the text while it is reading. I have already tried to add words to the TextToSpeech and display the word being read, as I show in the following code, but the fluency is not good when you order to read word by word compared to a complete sentence.

String[] list = {"My", "name", "is", "John"};
TextToSpeech tts = new TextToSpeech(this, this);
tts.setOnUtteranceProgressListener(new UtteranceProgressListener() {
        @Override
        public void onStart(String utteranceId) {
                textView.append(" " + list[k++]);
        }
        @Override
        public void onDone(String utteranceId) {
        }
        @Override
        public void onError(String utteranceId) {
        }
    });

... in the read order

for (String t: list){
    tts.speak(t, TextToSpeech.QUEUE_ADD, null, "ID");
}

So, what I need is to order reading a complete sentence and to display the words that are being read one by one.

来源:https://stackoverflow.com/questions/45870991/text-to-speech-show-read-words

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!