gpt4 book ai didi

java - 语音识别器 : no selected voice recognition service

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:39:09 26 4
gpt4 key购买 nike

这就是我开始 RecogniseListener Intent 的方式:

Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);   
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

intent.putExtra("android.speech.extra.DICTATION_MODE", true);
intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,this.getPackageName());
intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,1);
sr.startListening(intent);

但是,我有一个奇怪的行为。它适用于某些手机(三星 galaxy S5,在这种情况下),但我在 Lenovo K50-T5 上收到以下错误:

E/SpeechRecognizer: no selected voice recognition service

这是我的 AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="lips.deafcommunication.deaflips">

<uses-permission android:name="android.permission.RECORD_AUDIO" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppThemeNoBar">
<activity android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ChatInProgressActivity" android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboardHidden|orientation|screenSize"
></activity>
</application>
</manifest>

最佳答案

在我的案例中,如果默认情况下他/她未选择语音识别服务,则用户设备会发出此警告案例,这是解决此问题的设置照片,您在照片中看到默认情况下未选择任何服务,

enter image description here

通过显式添加 GoogleRecognitionService 到我的SpeechRecognizer 来解决这个问题,最后我的代码看起来像这样

 this.speechRecognizer = SpeechRecognizer.createSpeechRecognizer(getActivity(), ComponentName.unflattenFromString("com.google.android.googlequicksearchbox/com.google.android.voicesearch.serviceapi.GoogleRecognitionService"));

因此您的代码看起来像是在使用默认语音 Intent ,在这里创建您自己的自定义识别监听器链接到 How can I use speech recognition without the annoying dialog in android phones

注意:确保您已安装 Google app

关于java - 语音识别器 : no selected voice recognition service,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42912347/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com