gpt4 book ai didi

安卓语音识别器 Vuzix M300

转载 作者:太空宇宙 更新时间:2023-11-03 13:10:56 30 4
gpt4 key购买 nike

我有一个 Vuzix m300(更新 1.2),我正在尝试让我的应用程序通过语音控制运行。我真的找不到任何特定于 m300 的代码示例(我认为是因为它是新的?)。内置的语音识别器工作正常。但是当我尝试通过 android.speech.SpeechRecognizer 使用它时,我发现识别不可用...

我已经尝试了一些我在 Internet 上找到的代码,尽管有些代码应该可以在 m100 上运行。对我没有任何作用。

这是我的代码:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//grant access to internet
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
//set layout
setContentView(R.layout.activity_main);
boolean b = SpeechRecognizer.isRecognitionAvailable(getApplicationContext());
final List<ResolveInfo> services = getApplicationContext().getPackageManager().queryIntentServices(
new Intent(RecognitionService.SERVICE_INTERFACE), 0);
b = isPackageInstalled(this.getApplicationContext(), "com.google.android.googlequicksearchbox");
}
public static boolean isPackageInstalled(@NonNull final Context ctx, @NonNull final String packageName) {
try {
ctx.getApplicationContext().getPackageManager().getApplicationInfo(packageName, 0);
return true;
} catch (final PackageManager.NameNotFoundException e) {
return false;
}

b 始终为假,列表服务为空...因此我认为 Vuzix 上没有安装 SpeechRecongnizer,但是有(Vuzix 内置的?)。我愿意接受任何建议!

编辑:我已经安装了 Google Now App 和 Google App,现在我可以启动 SpeechRecognizer。但出于某种原因,该应用程序不会对我的声音使用react。一段时间后,我得到一个 SpeechRecognizer ERROR_SPEECH_TIMEOUT。同一个应用程序在我的 Android 手机上运行良好,所以我认为它与 Vuzix M300 有关?我在 onCreate 中的代码:

speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
speechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getApplication().getPackageName());
speechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "de-DE");
speechRecognizer.setRecognitionListener(prepareRegnitionListener());
speechRecognizer.startListening(speechRecognizerIntent);

及其他:

private RecognitionListener prepareRegnitionListener() {
// TODO Auto-generated method stub
return new RecognitionListener() {

@Override
public void onRmsChanged(float rmsdB) {
//Didn´t use
}

@Override
public void onResults(Bundle results) {
ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
Log.d(MainActivity,"Completed speech recognition: Result: " + matches);
String match = matches.get(0);
}

@Override
public void onReadyForSpeech(Bundle params) {
Log.d(MainActivity, "ReadyforSpeech");
}

@Override
public void onPartialResults(Bundle partialResults) {
// Nothing

}

@Override
public void onEvent(int eventType, Bundle params) {
// Nothing

}

@Override
public void onError(int error) {
switch (error){
case SpeechRecognizer.ERROR_AUDIO:
Log.e(MainActivity,"Failed to recognize speech: Audio recording error.");
startListening(1000);
break;
case SpeechRecognizer.ERROR_CLIENT:
Log.e(MainActivity,"Failed to recognize speech: Insufficient permissions.");
startListening(1000);
break;
case SpeechRecognizer.ERROR_NO_MATCH:

Log.d(MainActivity,"Failed to recognize speech: No recognition results matched. Retrying...");
startListening(1000);
break;
default:
Log.e(MainActivity,"Failed to recognize speech. Unknown error" + error);
startListening(1000);

}


}

@Override
public void onEndOfSpeech() {
Log.d(MainActivity, "EndofSpeech");
}

@Override
public void onBufferReceived(byte[] buffer) {
//Didn´t use

}

@Override
public void onBeginningOfSpeech() {
Log.d(MainActivity, "beginnofSpeech");//Do something when speaking starts
}
};
}

调用了 onReadyforSpeech 方法,但此后没有任何反应,而是抛出了错误。

最佳答案

我不熟悉 vuzix Android 版本,但显然它没有您需要的 Google 软件包。我也遇到了这个问题,我已经通过下载并安装 Google App 和 Google Now App 的 apk 解决了这个问题。

你可以在这里试试:

Google app

Google Now

关于安卓语音识别器 Vuzix M300,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45431794/

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