diff --git a/src/android/SpeechRecognition.java b/src/android/SpeechRecognition.java index 0c8a1f3..eebb744 100644 --- a/src/android/SpeechRecognition.java +++ b/src/android/SpeechRecognition.java @@ -64,6 +64,7 @@ else if (ACTION_SPEECH_RECOGNIZE_START.equals(action)) { } String lang = args.optString(0, "en"); + boolean interimResults = args.optBoolean(1); this.speechRecognizerCallbackContext = callbackContext; @@ -71,6 +72,7 @@ else if (ACTION_SPEECH_RECOGNIZE_START.equals(action)) { intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,"voice.recognition.test"); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE,lang); + intent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS,interimResults); intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS,5); @@ -128,15 +130,42 @@ private void fireRecognitionEvent(ArrayList transcripts, float[] confide JSONArray results = new JSONArray(); try { for(int i=0; i transcripts) { + Log.d(LOG_TAG,"hey, this is me. This is an interim result"); + JSONObject event = new JSONObject(); + JSONArray results = new JSONArray(); + try { + for(int i=0; i partial = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); + if(partial.size() > 0){ + fireInterimRecognitionEvent(partial); + } + } @Override public void onReadyForSpeech(Bundle params) { diff --git a/www/SpeechRecognition.js b/www/SpeechRecognition.js index 0ea6061..b3180d9 100644 --- a/www/SpeechRecognition.js +++ b/www/SpeechRecognition.js @@ -67,7 +67,7 @@ SpeechRecognition.prototype.start = function() { } }; - exec(successCallback, errorCallback, "SpeechRecognition", "start", [this.lang]); + exec(successCallback, errorCallback, "SpeechRecognition", "start", [this.lang,this.interimResults]); }; SpeechRecognition.prototype.stop = function() {