3

I have an Vuzix m300 (Update 1.2) and I am trying to get my app running with voice control. I really couldn't find any code samples specific for the m300 (I think due to it is to new?). The built in Speech Recognizer works fine. But when I try to use it via the android.speech.SpeechRecognizer I get that Recognition isn't Available...

I have tried some code I found on the Internet and although some code that should work on the m100. Nothing worked for me.

Here is my code:

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 is always false and the List services is empty... Therefore I would think that there is no SpeechRecongnizer installed on the Vuzix, but there is (The built in from Vuzix?). I am open for any suggestions!

Edit: I have installed the Google Now App and the Google App and now I can start an SpeechRecognizer. But for some Reason the App won't react to my voice. After some time I get an SpeechRecognizer ERROR_SPEECH_TIMEOUT. The same App works fine on my Android Phone, so I think it is something with the Vuzix M300? My code in 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);

and the Rest:

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
        }
    };
}

The onReadyforSpeech Method is called, but after that nothing happens and than the Error is getting thrown.

manderda
  • 80
  • 1
  • 8
  • I'm also tasting with the M300 and I'm unable to get Vuzix's voice recognition to work. What do you mean by 'The built in Speech Recognizer works fine'? I tried running the sample project from their website [link](http://files.vuzix.com/Content/Upload/Driver_File_VoiceControlSDK_1__20160317210049767.pdf) and it's compiling fine, but crashing at runtime because of some missing classes. – Alex Ionescu Sep 22 '17 at 11:29

2 Answers2

3

I'm not familiar with the vuzix Android version, but obviously it comes without the Google packages you need. I also had this issue and I've solved it by downloading and installing the apks for Google App and Google Now App.

You can try here:

Google app

Google Now

yakobom
  • 2,681
  • 1
  • 25
  • 33
  • Thanks a lot, that worked perfect. But shouldn't be there a method to use the highly praised "Truly Handsfree" service that is built in? – manderda Aug 01 '17 at 08:18
  • I have no experience with that. But try googling ACTION_VOICE_SEARCH_HANDS_FREE, it will lead you to some posts regarding it. – yakobom Aug 01 '17 at 08:42
1

To access the Vuzix built in Speech Recognition programmatically you first need to download and install the M300 SDK. See https://www.vuzix.com/Developer/KnowledgeBase/Detail/43

After the SDK is installed there is documentation in the Android sdk/add-ons/addon-vuzixm300sdk-vuzix-23/docs folder on how to use the built in speech recognition service. See https://www.vuzix.com/Developer/KnowledgeBase/Detail/45

The jar library (com.vuzix.sdk.speechrecognitionservice.jar) is located in the Android sdk/add-ons/addon-vuzixm300sdk-vuzix-23/libs folder.

Abdalrahman Shatou
  • 4,550
  • 6
  • 50
  • 79