[英]SpeechRecognizer, bind to recognition service failed
我在 android 上使用 SpeechRecognizer 来识别用户的声音。 在卸载 Google App 之前它运行良好。 ( https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox&hl=en )
我更新了谷歌应用程序,但出现“绑定识别服务失败”等错误。 如何使应用程序成功运行?
正常使用 SpeechRecognizer 应该怎么做?
谢谢。
我正在使用 Algolia 的语音输入库,但无法在 Pixel 2 和 android 11 设备上进行语音输入。 无法绑定语音识别服务的原因。
为了解决这个问题,在清单文件中,在你的开始标签下插入这个查询元素:
<queries>
<package android:name="com.google.android.googlequicksearchbox"/>
</queries>
我知道我回答这个问题有点晚了,但我已经与这个错误斗争了一段时间了。 事实证明,您需要激活 Google 的快速搜索框。 所以我使用的解决方案是:我检查isRecognitionAvailable(context)
是否可用(使用isRecognitionAvailable(context)
)。 如果 SpeechRecognizer 不可用,您可以像这样激活它:
if(!SpeechRecognizer.isRecognitionAvailable(mainActivity)){
String appPackageName = "com.google.android.googlequicksearchbox";
try {
mainActivity.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
mainActivity.startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}
}
每次 Google 应用以某种方式更新时,语音识别器回调总会出现问题。 要么谷歌定期更改他们的超时条款,要么像你这样的奇怪问题突然冒出来。
您需要使您的代码动态化,即使语音回调方法中存在错误,您也需要捕获该错误并再次尝试自动收听。 这已经在此广泛讨论后,有很多提供给您根据您的需要检查并实现它们的答案。
如果您不想要这个,您可以随时尝试DroidSpeech库,它可以在出现某些内容时处理这些语音错误问题,并为您提供持续的语音识别。
只需使用 Gradle 实现库并添加以下代码行即可。
DroidSpeech droidSpeech = new DroidSpeech(this, null); droidSpeech.setOnDroidSpeechListener(this);
要开始听用户调用以下代码,
droidSpeech.startDroidSpeechRecognition();
你会在监听器方法中得到语音结果,
@覆盖
public void onDroidSpeechFinalResult(String finalSpeechResult, boolean droidSpeechWillListen) {
}
您需要像这样在清单中添加它:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
**<queries>
<intent>
<action android:name="android.speech.RecognitionService" />
</intent>
</queries>**
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.