I am developing an Android Application that is based around Speech Recognition.
Until today everything has been working fine and in a timely manner, e.g. I would start my speech recogniser, speak, and within 1 or 2 seconds max the application received the results.
It was a VERY acceptable user experience.
Then today I now have to wait for ten or more seconds before the recognition results are available.
I have tried setting the following EXTRAS, none of which make any discernible difference
RecognizerIntent.EXTRA_SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS
RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS
RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS
I have been continually changing my application, however none of these changes were related to the speech recogniser.
Is there any method I can employ to reduce the time between the speech recogniser switching from onBeginningOfSpeech()
to onResults()
?
Heres an example of how long it takes
07-01 17:50:20.839 24877-24877/com.voice I/Voice: onReadyForSpeech()
07-01 17:50:21.614 24877-24877/com.voice I/Voice: onBeginningOfSpeech()
07-01 17:50:38.163 24877-24877/com.voice I/Voice: onEndOfSpeech()
NOTE! this works only in online mode. Enable dictation mode and disable partial results:
In dictation mode speechRecognizer would still call
onPartialResults()
however you should treat the partials as final results.EDIT - Has apparently been fixed in the August 2016 coming release You can test the beta to confirm.
This is a bug with the release of Google 'Now' V6.0.23.* and persists in the latest V6.1.28.*
Since the release of V5.11.34.* Google's implementation of the
SpeechRecognizer
has been plagued with bugs.You can use this gist to replicate many of them.
You can use this BugRecognitionListener to work around some of them.
I have reported these directly to the Now team, so they are aware, but as yet, nothing has been fixed. There is no external bug tracker for Google Now, as it's not part of AOSP, so nothing you can star I'm afraid.
The most recent bug you detail pretty much makes their implementation unusable, as you correctly point out, the parameters to control the speech input timings are ignored. Which according to the documentation:
is something we should expect......
The recognition will continue indefinitely if you don't speak or make any detectable sound.
I'm currently creating a project to replicate this new bug and all of the others, which I'll forward on and link here shortly.
EDIT - I was hoping I could create a workaround that used the detection of partial or unstable results as the trigger to know that the user was still speaking. Once they stopped, I could manually call
recognizer.stopListening()
after a set period of time.Unfortunately,
stopListening()
is broken too and doesn't actually stop the recognition, therefore there is no workaround to this.Attempts around the above, of destroying the recognizer and relying only on the partial results up until that point (when destroying the recognizer
onResults()
is not called) failed to produce a reliable implementation, unless you're simply keyword spotting.There is nothing we can do until Google fix this. Your only outlet is to email apps-help@google.com reporting the problem and hope that the volume they receive gives them a nudge.....
UPDATE: As of my testing today, this bug seems to have been resolved finally and this is no longer necessary. Leaving it in case it gets broke again in the future. From my tests, the speech timeout is working normally.
Ok, I know this is VERY UGLY, but it seems to work using onPartialResults (I understand the gotchas with onPartialResults but I've tried this a few times and it's something until Google fixes this ridiculous bug!) I haven't exhaustively tested it yet (I will and post back results as I will be using this in an app) but I was desperate for a solution. Basically, I'm using onRmsChanged to trigger that user is done speaking, assuming that when the RmsDb falls below peak and no onPartialResults for 2 seconds, we're done.
The one thing I don't like about this is destroying SR makes a double uh-oh beep. FWIW and YMMV. Please post any improvements!
NOTE: If you are going to use this repeatedly, don't forget to reset bBegin and fPeak! Also you will need to recreate SR (either onStartCommand or stop and start service.)
The best work around solution I found (until google fixes the bug) was to go in to the Google App App info and then click on "Uninstall Updates" button. This will remove all updates done to this app which has direct affect on the speech recognizer, basically returning it to factory.
**Probably a good idea to stop automatic updates until we know it's fixes. ***Note: this is a solution only for developers, obviously if you have an app in the store this will not help you. Sorry...
UPDATE:
Just in case if anyone is having trouble in setting up the speech recognition, you can use Droid Speech library which I built to overcome the speech time out issue in android.
My app was entirely dependent upon the voice recognition feature and Google has dropped a bomb. Going by the look of things, I believe this wouldn't be fixed at least in the near future.
For the time being, I did find a solution to have the google voice recognition deliver the speech results as intended.
Note: This approach slightly varies from the above mentioned solutions.
The main purpose of this method is to make sure the entire words uttered by the user is caught at onPartialResults().
In normal cases if a user speaks more than a single word at a given instance the response time is too quick and partial results will more often than not get only the first word and not the complete result.
So to make sure every single word is caught at onPartialResults() a handler is introduced to check the user pause delay and then filter the results. Also note the result array from onPartialResults() will more often than not have only a single item.
Solution for offline only:
I have encountered the same issue (Android system took 25 seconds to yield the transcript of the speech via
onPartialResults()
afteronEndOfSpeech()
is triggered.I have tried the following code and it worked:
This solution works for my app and it may work for you if you do not use the online mode (I downloaded the language package via the phone setting).