Android SpeechRecognizer Vuzix M300

我有一台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始终为false并且List服务为空…
因此,我认为Vuzix上没有安装SpeechRecongnizer,但是有(是Vuzix内置的吗?).
我愿意接受任何建议!

编辑:
我已经安装了Google Now应用程序和Google App,现在可以启动SpeechRecognizer.但是由于某种原因,该应用程序无法响应我的声音.一段时间后,我得到了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 one rror(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方法,但此后什么也没有发生,而且抛出了Error.

解决方法:

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

您可以在这里尝试:

Google app

Google Now

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...