如何停止IBM Watson文字转语音的StreamPlayer
How to stop StreamPlayer of IBM Watson text-to-speech
我正在尝试使用 IBM Watson 文本转语音在我的 Android 应用程序上将文本转换为音频输出。
这是我的依赖项
compile 'com.ibm.watson.developer_cloud:java-sdk:3.5.3'
compile 'com.ibm.watson.developer_cloud:android-sdk:0.2.1'
在这里我将字符串转换为音频
new StreamPlayer().playStream(textToSpeechService.synthesize(params[0], Voice.EN_LISA).execute());
问题是当我退出播放音频的 activity 时,音频一直在播放,而我希望它停止。
如果使用 android.speech.tts.TextToSpeech
我可以很容易地使用 TextToSpeech.stop()
但是如何使用 IBM Watson 文本到语音转换呢?
当我问这个问题时,该功能还不存在,所以我创建了 github 问题 https://github.com/watson-developer-cloud/android-sdk/issues/21 他们创建了一个拉取请求来解决这个问题。现在我们可以使用
streamPlayer.interrupt();
停止 StreamPlayer
我正在尝试使用 IBM Watson 文本转语音在我的 Android 应用程序上将文本转换为音频输出。 这是我的依赖项
compile 'com.ibm.watson.developer_cloud:java-sdk:3.5.3'
compile 'com.ibm.watson.developer_cloud:android-sdk:0.2.1'
在这里我将字符串转换为音频
new StreamPlayer().playStream(textToSpeechService.synthesize(params[0], Voice.EN_LISA).execute());
问题是当我退出播放音频的 activity 时,音频一直在播放,而我希望它停止。
如果使用 android.speech.tts.TextToSpeech
我可以很容易地使用 TextToSpeech.stop()
但是如何使用 IBM Watson 文本到语音转换呢?
当我问这个问题时,该功能还不存在,所以我创建了 github 问题 https://github.com/watson-developer-cloud/android-sdk/issues/21 他们创建了一个拉取请求来解决这个问题。现在我们可以使用
streamPlayer.interrupt();
停止 StreamPlayer