I am trying to create the service which allows to continuously run the Android speech recognition engine. I have seen an example at Android Speech Recognition as a service on Android 4.1 & 4.2, and took it, but somehow i am always getting the SpeechRecognizer.ERROR_NO_MATCH error in the listener onError() method regardless of what is said. Of course, onResults() is never called. The code of the service is exactly as has been shown in the answer linked above, my code to start it is:
Intent startServiceIntent = null;
Log.d(TAG, "Creating new intent for the recognition service");
startServiceIntent = new Intent(getApplicationContext(), SpeechRecognitionService.class);
Log.d(TAG, "Starting the speech recognition service ...");
getApplicationContext().startService(startServiceIntent);
int duration = Toast.LENGTH_LONG;
CharSequence text = "Starting speech recognition ...";
Toast toast = Toast.makeText(getApplicationContext(), text, duration);
toast.show();
But when I directly call the speech recognition engine by sending Intent, it works just fine:
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Start talking");
intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10);
startActivityForResult(intent, 1234);
All my test I am running on Note2 with Android 4.1.2 on it. Has anyone faced this problem and might know how to solve this? Thanks