Home > Mobile >  Android comes with TextToSpeech on how to implement broadcast, next, circulating current sentence?
Android comes with TextToSpeech on how to implement broadcast, next, circulating current sentence?

Time:09-28

Good and, most recently in learning language class in writing a App, need TTS function to realize to the sentence order, stop, before, after, circulating current,
Now the input text processing, with an array of strings to store every word,

Play button code below
 
List String=TxtReader. GetStringList (inputStream1);
String [] sentenceArray=String. ToArray (new String [0]).
SENTENCE=sentenceArray [r]. Split (" (? <=[\ n]) ");
For (int r=1; Rfor (int i=0; iString toSpeak=what [I] the toString ();
System. The out. Println (" to speak: "+ toSpeak);
MSpeech. Speak (toSpeak, TextToSpeech. QUEUE_ADD, null);//QUEUE_FLUSH not work
}
}

Consult the rewind, forward, repeat key code can be done with what method?

CodePudding user response:

XxLanguageService service; Play the sentences on the service management
NextBtn. SetOnClickListener (v - & gt; Speak (service. GetNext ());
RepeatBtn. SetOnClickListener (v - & gt; Speak (service. GetCur ());
.

CodePudding user response:

Thank Daniel for the idea of service management are not ripe, then solved by the following way, thanks again,

 
Private class ttsUtteranceListener extends UtteranceProgressListener {
@ Override
Public void onStart (String utteranceId) {
Curr + +;
System. The out. Println (" current sentence: "+ curr);
}
@ Override
Public void onDone (String utteranceId) {

}

@ Override
Public void one rror (String utteranceId) {

}
}