2

The SpeechRecognizer was working properly for a quite a long time ,all of a sudden it is not working it is not detecting anything now .. the sample code is like this .When it is online it works properly but not in offline ,am i missing anything anywhere???

    SpeechRecognizer speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
    Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    i.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 1);
    speechRecognizer.setRecognitionListener(new RecognitionListener() {
        @Override
        public void onReadyForSpeech(Bundle params) {

        }

        @Override
        public void onBeginningOfSpeech() {

        }

        @Override
        public void onRmsChanged(float rmsdB) {

        }

        @Override
        public void onBufferReceived(byte[] buffer) {

        }

        @Override
        public void onEndOfSpeech() {
            //speechRecognizer.stopListening();
        }

        @Override
        public void onError(int error) {

        }

        @Override
        public void onResults(Bundle results) {
            List<String> data = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
            String full = data.get(0);
            System.out.println(full);
        }

        @Override
        public void onPartialResults(Bundle partialResults) {

        }

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

        }
    });
    speechRecognizer.startListening(i);`
  • Which speech recognizer are you using (name and version number)? Without this information the question is as meaningless as "keyboard is not working, why?" or "the default browser is not working, why?" – Kaarel May 13 '15 at 17:25

2 Answers2

4

Speech Recognicion only works online by default. The Recognition process demands large memory allocation, if you want an offline engine, you should avoid using the default Android Recognition service.

Take a look this post.

Community
  • 1
  • 1
Victor
  • 8,309
  • 14
  • 80
  • 129
0

Offline recognition using google's api only works on devices running Jellybean, and even for that to work, the language's packages must be installed on the target device.

If you are targeting all OS versions, I'd recommend using CMUSphinx. It works offline and supports continuous speech recognition. You can try the demo here

Nana Ghartey
  • 7,901
  • 1
  • 24
  • 26