是否RecognitionListener.onError()自动SpeechRecognizer.cancel()? [英] Does RecognitionListener.onError() automatically SpeechRecognizer.cancel()?

查看:392
本文介绍了是否RecognitionListener.onError()自动SpeechRecognizer.cancel()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于种种原因,我需要使用,而不是原始的 SpeechRecognizer API更容易 RecognizerIntent (RECOGNIZE_SPEECH)< A HREF =htt​​p://hi-android.info/src/android/speech/RecognitionService.java.html>活动。

For various reasons, I need to use the raw SpeechRecognizer API instead of the easier RecognizerIntent (RECOGNIZE_SPEECH) activity.

这意味着,除其他事项外,我需要处理 RecognitionListener.onError()我自己。

That means, among other things, that I need to handle RecognitionListener.onError() myself.

在回应一些错误,我只是想重新开始听。这看起来简单,但我只是叫 SpeechRecognizer.startListening()时的错误,这有时似乎引发两种不同的错误:

In response to some of the errors, I simply want to re-start listening. This looks straightforward but when I just call SpeechRecognizer.startListening() upon error, this sometimes seems to trigger two different errors:

 ERROR/ServerConnectorImpl(619): Previous session not destroyed

"concurrent startListening received - ignoring this call"

这暗示我应该尝试调用之前做了一些清理 SpeechRecognizer.startListening()了。

如果这是真的,这意味着在一个RecognitionListener错误,倾听不会自动停止和/或取消。

If this is true, it means that upon a RecognitionListener error, listening is not automatically stopped and/or canceled.

这也可能是一些错误就停止/取消听力,而有的则没有。其实只有9 SpeechRecognizer 错误:

It is also possible that some errors do stop/cancel listening, while others don't. There are really only 9 SpeechRecognizer errors:

  1. ERROR_NETWORK_TIMEOUT
  2. ERROR_NETWORK
  3. ERROR_AUDIO
  4. ERROR_SERVER
  5. ERROR_CLIENT
  6. ERROR_SPEECH_TIMEOUT
  7. ERROR_NO_MATCH
  8. ERROR_RECOGNIZER_BUSY
  9. ERROR_INSUFFICIENT_PERMISSIONS

由于该文件是不是很详细哪些错误取消听,这不,你可知道,根据您的经验,哪些错误需要做清理(以及在何种程度上)的尝试 SpeechRecognizer.startListening()了吗?

Since the documentation isn't very detailed about which error cancels listening and which doesn't, do you happen to know, based on your experience, which errors require doing cleanup (and to which extent) before attempting SpeechRecognizer.startListening() again?

推荐答案

没有,取消不叫当的onError 被调用。你可以看一下源<一href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/speech/SpeechRecognizer.java;h=8fa0d593d87b5cc158c114fe2b95a72053091898;hb=HEAD"相对=nofollow>这里。

No, cancel is not called when onError is invoked. You can look at the source here.

这篇关于是否RecognitionListener.onError()自动SpeechRecognizer.cancel()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆