本文介绍了是否RecognitionListener.onError()自动SpeechRecognizer.cancel()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 由于种种原因,我需要使用,而不是原始的 SpeechRecognizer API更容易 RecognizerIntent (RECOGNIZE_SPEECH)活动。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: ERROR_NETWORK_TIMEOUT ERROR_NETWORK ERROR_AUDIO ERROR_SERVER ERROR_CLIENT ERROR_SPEECH_TIMEOUT ERROR_NO_MATCH ERROR_RECOGNIZER_BUSY 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 被调用。你可以看一下源这里。No, cancel is not called when onError is invoked. You can look at the source here. 这篇关于是否RecognitionListener.onError()自动SpeechRecognizer.cancel()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-16 07:51