如何处理ERROR_RECOGNIZER_BUSY
在我基于语音识别的应用程序中,我有时会收到 ERROR_RECOGNIZER_BUSY。直观上,这需要...重试,对吗?
问题是这个错误没有记录,所以显然我有一些问题,也许该领域更有经验的人能够回答:
- 什么触发了这样的错误?是吗 真的只有繁忙的服务器(在谷歌)? 或者这也可能暗示我的应用程序中存在错误?
- 我是否必须明确关闭/重新打开 重试之前的会话?
- 多久重试一次?每隔一次 1秒?每 5 秒一次?其他?
我们非常欢迎您的经验丰富的见解。谢谢。
In my voice recognition based app, I sometimes receive ERROR_RECOGNIZER_BUSY. Intuitively, this calls for... retries, right?
The problem is that this error is very undocumented, so obviously I have questions that perhaps someone more experienced in the field is able to answer:
- What triggers such an error? Is it
really only busy server (at Google)?
or this could also hint at a bug in my app? - Do I have to explicitly close/reopen
a session before a retry? - How often to retry? once every
1-second? every 5-seconds? Other?
Your experienced insights are most welcome. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我不是 100% 确定这一点,但是既然你发帖已经很久了,我不妨试一试。
看来您在代码中做错了什么。正如评论者所说,如果您实际发布返回此错误的代码,将会很有帮助。
但是,在 Android 语音识别服务的源代码中可以找到:
http://source-android.frandroid.com/frameworks/base/core/java/android/speech/RecognitionService.java
我们有一个名为
dispatchStopListening
的函数,它似乎会结束监听过程。然而,在它真正结束之前,有一些非法状态的检查,包括:这似乎意味着您正试图结束由其他人而不是您开始的监听过程,这会引发此错误。
我希望这会有所帮助,但如果您发布代码将会非常有益。
I'm not 100% sure of this, however since it's been so long since you posted, I may as well give it a shot.
It seems that you are doing something wrong in the code. As the commenter said, it would be helpful if you actually posted the code that is returning this error.
However, in the source code for the Android speech recognition service found here:
http://source-android.frandroid.com/frameworks/base/core/java/android/speech/RecognitionService.java
we have a function called
dispatchStopListening
which seems to end the listening process. However, before it actually ends it, there are a few checks for illegal states, including this:This seems to imply that you are trying to end the listening process by some other guy than you started it with, which raises this error.
I hope this helps, but it would be extremely beneficial if you posted the code.
这实际上是一个非常简单的错误。这意味着前面的聆听还没有完成。基本上,你需要停止倾听。在我的应用程序中,我有 2 个用于不同语言的按钮。调用 stopListening() 解决了该问题。该错误确实偶尔会出现,但现在用户体验很流畅。它不会造成问题。
This actually is a very simple error. It means the previous listening is not finished. Basically, you need to stop listening. In my App i have 2 button for different languages. calling stopListening() fixed the issue. The error does appear from time to time but the user experience is smooth now. It doesn't cause problems.
当您已经在使用 SpeechRecognizer 对象时,通常会引发 ERROR_RECOGNIZER_BUSY。 (或者你没有正确关闭一个)。
ERROR_RECOGNIZER_BUSY is often thrown when you are already in use of the SpeechRecognizer object. (Or you didn't close one proprely).
只需将包添加到您的识别器意图中,它就应该可以工作。这就是我所做的。
Simply add the package to your recognizer intent and it should work. That is what I have done.
ERROR_RECOGNIZER_BUSY 最可能的原因是您没有从主线程停止识别服务并且抛出的错误被忽略。
The most likely cause for ERROR_RECOGNIZER_BUSY is that you have not stopped the recognition service from the main thread and the error thrown was ignored.