问题
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