【问题标题】:SpeechRecognizer, bind to recognition service failedSpeechRecognizer,绑定到识别服务失败
【发布时间】:2017-09-01 02:05:47
【问题描述】:

我在 android 上使用 SpeechRecognizer 来识别用户的声音。 在卸载 Google App 之前它运行良好。 (https://play.google.com/store/apps/details?id=com.google.android.googlequicksearchbox&hl=en)

我更新了谷歌应用,但出现“绑定识别服务失败”等错误。 如何让应用成功运行?

正常使用 SpeechRecognizer 应该怎么做?

谢谢。

【问题讨论】:

标签: android speech-recognition bindservice


【解决方案1】:

更新清单

我正在使用 Algolia 的语音输入库,但它无法在 Pixel 2 和 android 11 设备上进行语音输入。无法绑定语音识别服务的原因。

为了解决这个问题,在清单文件中,将这个查询元素插入到您的开始标签下方:

<queries>
        <package android:name="com.google.android.googlequicksearchbox"/>
</queries>

【讨论】:

  • 谢谢! 2021 年仍然是实际情况,您的回复是解决 Pixel 3a 问题的唯一方法。
  • 这个答案应该是正确的解决方案。谢谢芽
  • 按意图过滤也可以&lt;queries&gt; &lt;intent&gt; &lt;action android:name="android.speech.RecognitionService" /&gt; &lt;/intent&gt; &lt;/queries&gt;
  • 还有谁会觉得这简直太疯狂了,甚至与任何与SpeechRecognizer 相关的文档都不在话下?这是 2021 年。还是什么都没有。
【解决方案2】:

我知道我回答这个问题有点晚了,但我已经为这个错误苦苦挣扎了一段时间。事实证明,您需要激活 Google 的快速搜索框。所以我使用的解决方案是:我检查 SpeechRecognizer 是否可用(使用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)));
    }
}

【讨论】:

  • 对我不起作用,它只是用谷歌应用打开了一个 PlayStore 页面。在清单中添加“查询”(见上文)解决了 Pixel 3a 上的问题。
  • @ARA1307 我认为正确的解决方案是将这两种解决方案结合起来,因为有些客户没有在他们的设备上安装/启用 Google 的快速搜索框(仅通过添加“查询”无法解决)到你的清单)。无论如何,很高兴其他解决方案对您有用:)
【解决方案3】:

每次以某种方式更新 Google 应用时,语音识别器回调总是会出现问题。 Google 会定期更改他们的超时条款,或者像您这样的奇怪问题突然出现。

您需要以这样的方式使您的代码动态化,即使语音回调方法中存在错误,您也需要捕获该错误并再次尝试自动收听。这已在此 post 中进行了广泛讨论,并提供了大量答案供您根据您的要求检查和实施它们。

如果您不希望这样,您可以随时尝试DroidSpeech 库,它会在出现问题时处理这些语音错误问题,并为您提供持续的语音识别。

只需使用 Gradle 实现该库并添加以下代码行即可。

DroidSpeech droidSpeech = new DroidSpeech(this, null); droidSpeech.setOnDroidSpeechListener(this);

要开始监听用户调用下面的代码,

droidSpeech.startDroidSpeechRecognition();

你会在监听器方法中得到语音结果,

@Override

public void onDroidSpeechFinalResult(String finalSpeechResult, boolean droidSpeechWillListen) {

}

【讨论】:

    猜你喜欢
    • 2015-11-06
    • 1970-01-01
    • 2022-06-26
    • 1970-01-01
    • 2020-04-23
    • 1970-01-01
    • 2021-02-22
    • 1970-01-01
    • 2020-08-01
    相关资源
    最近更新 更多