I have an activity that creates an “Audio” class and tries to use the Android API for speech to read text. If the language is not supported, he tries to use MediaPlayer to play a custom mp3 file from the server. Finally, if MediaPlayer does not work, it uses Nuance SpeechKit to read the text:

My problem is when I destroy an action, I want to destroy / stop the Nuance sound, and I'm not sure how to mute the Nuance sound.
Action class
private Audio audio;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.my_layout);
audio = new Audio(this).play("my text to read");
}
@Override
protected void onPause() {
audio.pause();
super.onPause();
}
@Override
protected void onDestroy() {
audio.destroy();
super.onDestroy();
}
Audio class
private TextToSpeech tts;
private MediaPlayer player;
private Session session;
public void play(String text) {
if (supported) tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
else mediaPlayer(text);
}
private void mediaPlayer(String text) {
if (queryFoundFile) {
player = new MediaPlayer();
player.setDataSource(myFileUrl);
player.setAudioStreamType(3);
player.prepare();
player.start();
} else nuancePlayer(text);
}
private void nuancePlayer(String text) {
Transaction.Options options = new Transaction.Options();
options.setLanguage(new Language("eng-USA"));
session = Session.Factory.session(activity, myServer, appKey);
session.speakString(text, options, new Transaction.Listener() {
@Override
public void onError(Transaction transaction, String s, TransactionException e) {
e.printStackTrace()
}
});
}
public void pause() {
if (tts != null) tts.stop();
if (player != null) player.stop();
if (nuance != null) nuance.getAudioPlayer().stop();
}
public void destroy() {
if (tts != null) tts.shutdown();
if (player != null) player.release();
if (nuance != null) nuance.getAudioPlayer().stop();
}
If I use Text to Speech or MediaPlayer, and if I destroy my activity, the sound will be destroyed immediately. But I can’t destroy the sound if the Nuance is playing. He just keeps talking.
pause() destroy(). nuance.getAudioPlayer AudioPlayer. , , stop() .
?
, Nuance, . Android Text to Speech.
Nuance
?
4 , . , , Nuance.
Nuance ?
Nuance . android TTS MediaPlayer. , Nuance. , !