How to stop StreamPlayer of IBM Watson text-to-speech

466 views Asked by At

I am trying to use IBM Watson text-to-speech to convert text to audio output on my Android application. Here is my dependencies

compile 'com.ibm.watson.developer_cloud:java-sdk:3.5.3'
compile 'com.ibm.watson.developer_cloud:android-sdk:0.2.1'

Here where i convert string to audio

new StreamPlayer().playStream(textToSpeechService.synthesize(params[0], Voice.EN_LISA).execute());

The problem is when i quit the activity where i play the audio, the audio keeps playing on while i want it to be stopped.

If use android.speech.tts.TextToSpeech i can easily use TextToSpeech.stop() but how to do it with IBM Watson text-to-speech?

1

There are 1 answers

0
HendraWD On BEST ANSWER

When i asked this question, the functionality doesn't exist yet, so i created github issue https://github.com/watson-developer-cloud/android-sdk/issues/21 and they created a pull request to solve the problem. Now we can use

streamPlayer.interrupt();

to stop StreamPlayer