我想让TTS在后台运行.但是,我从来没有听到任何声音.我有一个广播接收器启动服务.我把我的TTS代码放在这两个代码中,但它从不说话.我知道正在调用该方法(我在其上设置了一个断点),但它仍然不起作用.
这是我的日志,但似乎没有包含有关TTS服务的任何内容.
10-04 22:45:30.663: WARN/inputManagerService(209): Window already focused, ignoring focus gain of: com.androID.internal.vIEw.IinputMethodClIEnt$Stub$Proxy@4423df4010-04 22:45:37.363: INFO/PollingManager(449): calculateShortestInterval(): shortest interval is 54000010-04 22:45:37.413: INFO/TLsstateManager(449): org.apache.harmony.nio.internal.socketChannelimpl@4400ece0: Wrote out 29 bytes of data with 0 bytes remaining.10-04 22:45:38.043: ERROR/IMAPEmailService(480): Can't create default IMAP system folder Trash. Please reconfigure the folder names.10-04 22:45:40.123: ERROR/EONS(303): EF_PNN: No short name10-04 22:45:41.543: ERROR/WMSTS(171): Month is invalID: 010-04 22:45:42.043: WARN/audioflinger(172): write blocked for 212 msecs, 24 delayed writes, thread 0xb998
提前谢谢大家!
解决方法:
有助于查看您的TTS代码,以便人们更轻松地为您提供帮助.由于我已经在broadcastReceiver中使用了TTS,这里是一个从我的代码中删除的示例.
public static class TTS extends Service implements TextToSpeech.OnInit@R_419_6818@ener, OnUtteranceCompleted@R_419_6818@ener { private TextToSpeech mTts; private String spokenText; @OverrIDe public voID onCreate() { mTts = new TextToSpeech(this, this); // This is a good place to set spokenText } @OverrIDe public voID onInit(int status) { if (status == TextToSpeech.SUCCESS) { int result = mTts.setLanguage(Locale.US); if (result != TextToSpeech.LANG_MISSING_DATA && result != TextToSpeech.LANG_NOT_SUPPORTED) { mTts.speak(spokenText, TextToSpeech.QUEUE_FLUSH, null); } } } @OverrIDe public voID onUtteranceCompleted(String uttID) { stopSelf(); } @OverrIDe public voID onDestroy() { if (mTts != null) { mTts.stop(); mTts.shutdown(); } super.onDestroy(); } @OverrIDe public IBinder onBind(Intent arg0) { return null; }}
在broadcastReceiver中您希望它发言的位置启动TTS服务:
context.startService(new Intent(context, TTS.class));
如果不是提问者,我希望这可以帮助别人(我确信他现在已经开始工作了).
总结以上是内存溢出为你收集整理的从广播接收器或服务启动Android TTS全部内容,希望文章能够帮你解决从广播接收器或服务启动Android TTS所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)