Je dois démarrer une animation pouvant être dessinée lorsque mon texte à partir de la parole commence et arrêter celui-ci lorsque le texte à la parole est terminée, mais je ne peux pas arrêter l'animation.Faire quelque chose lorsque la synthèse vocale est terminée
code:
tts = new TextToSpeech(this, new TextToSpeech.OnInitListener() {
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
int result = tts.setLanguage(Locale.US);
if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {
Log.e("TTS", "This Language is not supported");
}
} else {
Log.e("TTS", "Initilization Failed!");
}
}
});
private void speak(String text){
animation.start();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null, null);
}else{
tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
}
}
et ici mon animationdrawable xml
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/selected" android:oneshot="false" >
<item android:drawable="@drawable/face_1a_mini" android:duration="250" />
<item android:drawable="@drawable/face_1b_mini" android:duration="250" />
<item android:drawable="@drawable/face_1c_mini" android:duration="250" />
<item android:drawable="@drawable/face_1d_mini" android:duration="250" />
</animation-list>
Salut et bienvenue à débordement de la pile, s'il vous plaît prendre le temps de passer par la [bienvenue tournée] (https://stackoverflow.com/tour) de connaître votre chemin ici (et aussi pour gagner votre premier insigne), lisez comment créer un [exemple minimal, complet et vérifiable] (https://stackoverflow.com/help/mcve) et également [Comment poser de bonnes questions] (https://stackoverflow.com/help/ Comment demander) afin d'augmenter vos chances d'obtenir des commentaires et des réponses utiles. – DarkCygnus
Copie possible de [Comment savoir quand TTS est fini?] (Https://stackoverflow.com/questions/4658376/how-to-know-when-tts-is-finished) –