Java Android TextToSpeech引擎未绑定,但首次运行时未绑定
我正在尝试编写一个超级简单的应用程序,当点击一个按钮时,它可以进行TextToSpeech 我运行了应用程序,第一次,TTS工作了!(我听到它说话)。当我再次运行它时(还有很多次),它没有说话,即使代码保持不变。有人能告诉我怎么做吗 我想我遗漏了一些关于TTS工作原理的基本信息,因此如果你能为一个傻瓜解释一下,我将非常感激。Java Android TextToSpeech引擎未绑定,但首次运行时未绑定,java,android,text-to-speech,Java,Android,Text To Speech,我正在尝试编写一个超级简单的应用程序,当点击一个按钮时,它可以进行TextToSpeech 我运行了应用程序,第一次,TTS工作了!(我听到它说话)。当我再次运行它时(还有很多次),它没有说话,即使代码保持不变。有人能告诉我怎么做吗 我想我遗漏了一些关于TTS工作原理的基本信息,因此如果你能为一个傻瓜解释一下,我将非常感激。 非常感谢你,朱利叶斯 以下是布局文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res
非常感谢你,朱利叶斯 以下是布局文件:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="test1"
android:text="Test" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open local DB" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open global DB" />
</LinearLayout>
最后(感谢阅读到现在为止……)这里是日志:
05-11 14:57:35.149 30221 30221 I art com.mycompany.myapp Late-enabling -Xcheck:jni
05-11 14:57:35.460 30221 30221 I TextToSpeech com.mycompany.myapp Sucessfully bound to com.google.android.tts
05-11 14:57:35.470 30221 30246 D OpenGLRenderer com.mycompany.myapp Use EGL_SWAP_BEHAVIOR_PRESERVED: true
05-11 14:57:35.535 30221 30221 D Atlas com.mycompany.myapp Validating map...
05-11 14:57:35.639 30221 30246 I Adreno-EGL com.mycompany.myapp <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 01/14/15, ab0075f, Id3510ff6dc
05-11 14:57:35.641 30221 30246 I OpenGLRenderer com.mycompany.myapp Initialized EGL, version 1.4
05-11 14:57:35.666 30221 30246 D OpenGLRenderer com.mycompany.myapp Enabling debug mode 0
05-11 14:57:35.907 30221 30221 I TextToSpeech com.mycompany.myapp Connected to ComponentInfo{com.google.android.tts/com.google.android.tts.service.GoogleTTSService}
05-11 14:57:35.918 30221 30268 I TextToSpeech com.mycompany.myapp Set up connection to ComponentInfo{com.google.android.tts/com.google.android.tts.service.GoogleTTSService}
05-11 14:57:35.919 30221 30221 I System.out com.mycompany.myapp success!!!
05-11 14:57:36.917 30221 30221 I System.out com.mycompany.myapp Starting test.....
05-11 14:57:36.985 30221 30246 V RenderScript com.mycompany.myapp Application requested CPU execution
05-11 14:57:37.005 30221 30246 V RenderScript com.mycompany.myapp 0xb4819e00 Launching thread(s), CPUs 4
05-11 14:57:38.465 30221 30221 W TextToSpeech com.mycompany.myapp stop failed: not bound to TTS engine
05-11 14:57:38.465 30221 30221 W TextToSpeech com.mycompany.myapp shutdown failed: not bound to TTS engine
05-11 14:57:35.149 30221 30221 I art com.mycompany.myapp延迟启用-Xcheck:jni
05-11 14:57:35.460 30221 30221 I TextToSpeech com.mycompany.myapp成功绑定到com.google.android.tts
05-11 14:57:35.470 30221 30246 D OpenGLRenderer com.mycompany.myapp使用EGL交换行为保存:true
05-11 14:57:35.535 30221 30221 D Atlas com.mycompany.myapp验证地图。。。
05-11 14:57:35.639 30221 30246 I Adreno EGL com.mycompany.myapp:QUALCOMM Build:01/14/15,ab0075f,Id3510ff6dc
05-11 14:57:35.641 30221 30246 I OpenGLRenderer com.mycompany.myapp初始化EGL,版本1.4
05-11 14:57:35.666 30221 30246 D OpenGLRenderer com.mycompany.myapp启用调试模式0
05-11 14:57:35.907 30221 30221 I TextToSpeech com.mycompany.myapp连接到组件信息{com.google.android.tts/com.google.android.tts.service.googlettssservice}
05-11 14:57:35.918 30221 30268 I TextToSpeech com.mycompany.myapp设置到组件信息{com.google.android.tts/com.google.android.tts.service.googlettssservice}的连接
05-11 14:57:35.919 30221 30221 I System.out com.mycompany.myapp成功!!!
05-11 14:57:36.917 30221 30221 I System.out com.mycompany.myapp启动测试。。。。。
05-11 14:57:36.985 30221 30246 V RenderScript com.mycompany.myapp应用程序请求CPU执行
05-11 14:57:37.005 30221 30246 V RenderScript com.mycompany.myapp 0xb4819e00启动线程,CPU 4
05-11 14:57:38.465 30221 30221 W TextToSpeech com.mycompany.myapp停止失败:未绑定到TTS引擎
05-11 14:57:38.465 30221 30221 W TextToSpeech com.mycompany.myapp关机失败:未绑定到TTS引擎
再次感谢
公共无效关闭()释放TextToSpeech引擎使用的资源。例如,将其称为 方法,以便TextToSpeech 发动机可以完全停止 参考: 由于这个原因,TTS只能在第一次工作时使用,您可以释放TextToSpeech的资源 您应该删除
Speaker.shutdown()代码>从test1
输入到ondestory
:
@Override
protected void onDestroy() {
Speaker.shutdown();
super.onDestroy();
}
@Override
protected void onDestroy() {
Speaker.shutdown();
super.onDestroy();
}