is there a way to reduce the listening time for voice recognition ?

731 views
Skip to first unread message

Clémentine

unread,
Dec 19, 2016, 11:09:05 AM12/19/16
to DroidScript
Hello

I'm testing the voice recognition feature for a language app.
Currently speech.SetOnResult(callback) takes 20 seconds before the callback is called (between the 2 beep sounds).

It's quite long when you only have one word to say.
Is there a way of reducing it, like 5 to 10 seconds ?

Thanks,
Clementine

Steve Garman

unread,
Dec 19, 2016, 11:22:05 AM12/19/16
to DroidScript
You could try using the "partial" option

speech = app.CreateSpeechRec( "partial" );

Clémentine

unread,
Dec 19, 2016, 11:28:12 AM12/19/16
to DroidScript

Thanks Steve for your prompt reply.

I have seen the partial option in an example but I have no clue how to use it.

Would you be able to explain what it does ?

Thanks


Steve Garman

unread,
Dec 19, 2016, 11:36:03 AM12/19/16
to DroidScript
I think it makes multiple calls to the callback every time it thinks it has recognised something.

There is a parameter to the callback which indicates whether it is a partial match or has finished listening.

Partial matches are likely to be less accurate than full matches but if you are looking for a specific one-word reply, that may be enough for you.

I don't remember the details offhand. Will post back in a few minutes.

Clémentine

unread,
Dec 19, 2016, 12:15:18 PM12/19/16
to DroidScript
Ok, great. Will be waiting for your reply.;

I have tested putting "partial" in app.CreateSpeechRec( "partial" );

then calling SetOnResult with the following callback:
var speech_OnResult = function(results, partial ){
    console.log(results[0]);
    console.log(partial); 
}

It returns partial results (null, true) 7 times then the final results ("what I said", false), but all at once, in the end (after 20 seconds).

Wondering if the partial results can be obtained before the final results.

Steve Garman

unread,
Dec 19, 2016, 12:40:38 PM12/19/16
to DroidScript
My understanding is that it is supposed to do what you are asking for.

However, I am getting the same result as you at the moment.

I am not sure it is going to be much help to you. Sorry.

Dave Smart

unread,
Dec 19, 2016, 1:58:24 PM12/19/16
to DroidScript
Hi Clémentine,

The speech recognizer should throw an error and stop after a few seconds if no speech is heard.  In the DS sample this results in the "Please speak more clearly!" message.  Also it should stop recognizing after pause of about 2 seconds of talking but this stuff is a bit dependent on hardware.

If yours is running for 20 seconds, then it might be because you have some strong background noise which is keeping it listening. Is that the case?


Steve Garman

unread,
Dec 19, 2016, 2:05:58 PM12/19/16
to DroidScript
Hi Dave,

That was the problem with my tests. I was testing "partial" in a noisy carpark and getting the same results as Clémentine.

Now I am back home I get the expected result and probably do not even need the "partial"

Dave Smart

unread,
Dec 19, 2016, 2:38:50 PM12/19/16
to DroidScript
OK, I've just done some tests and also found out that if you don't use the "NoBeep" option, then the Android beeps register as an attempt to speak (due to the sound emanating from the speakers) and cause an error to be triggered in the speech recognizer (which is a bit daft really).

So I recommend using the DS NoBeep option or turning down the 'system' and 'music' stream volumes during recognition.

I've also just added a new 'minLen' parameter to the Recognize() method which allows you to keep the recognition going for a long period, which might be useful for continuous recognition (but this does not help with the beep problem).


Clémentine

unread,
Dec 25, 2016, 1:34:04 PM12/25/16
to DroidScript
An update after a few days of playing with SpeechRecognition..

I got it to work very well when the device is online. 

My earlier problem turned out to be a language setting problem. Not the same language setting for the device and for the speech recognition engine.
I also had to update "Google Launcher 3", from where the speech recognition engine is drawn. 

I also got it to work offline pretty well on my Mashmallow devices.

But, and it's a big but.. It still works rubbish when offline on lollipop devices. 

It gives the correct result but it takes ages to do so. Like 20-30 seconds.
And it's not a background noise problem, for sure.

Any idea what could be wrong and how to fix this ?

Merry Christmas!

Dave Smart

unread,
Dec 29, 2016, 2:40:15 PM12/29/16
to DroidScript
Hi Clementine,

I never updated the "Google Launcher 3" when I installed off-line voice recognition on my devices. I'm pretty sure I just went into the Android 'language and input' settings and did it from there.  Perhaps you need to try that on the Lollipop devices.

Note: I've recently made some improvements to the reliability of the continuous voice recognition, but I doubt that will help you in this case.

Regards
David
Reply all
Reply to author
Forward
0 new messages