I'm trying to create an HTML5-powered voice-controlled editor using the Speech Recognition API. Currently, the problem is when you start recording, it only lasts for a certain amount of time (basically until the user stops talking).
I can set continuous
and interimResults
to true
, but that doesn't keep it recording forever. It still ends.
I can also tell it to start again during the end event, but then it asks for permission every time, which is highly disruptive.
Is there a way to allow it to go continuously while only having to ask a user once?
Continuous speech recognition systems allow the user to talk to the system without stops and pauses. Continuous speech recognition systems can recognize more utterances than a command-and-control system. The guidelines for continuous speech recognition differ somewhat from those for command-and-control.
There are limitations to speech recognition software. It does not always work across all operating systems. Noisy environments, accents and multiple speakers may degrade results. Also, regular voice recognition software can lack integration with other key services.
Automated speech recognition (ASR) is a technology that allows users of information systems to speak entries rather than punching numbers on a keypad. ASR is used primarily to provide information and to forward telephone calls.
No matter the settings you'll choose, Google Chrome stops the speech recognition engine after a while... there's no way around it.
The only reliable solution I've found for continuous speech recognition, is to start it again by binding to the onend()
event, as you've suggested.
If you try a similar technique, be aware of the following:
If you are not on HTTPS, the user will be prompted to give permission over and over again on each restart. For this, and many other reasons, don't compromise on HTTP when using Speech Recognition.
Make sure you are not restarting the speech recognition immediately onend() without some safeguards to make sure you aren't putting the browser into an endless loop (e.g. two open tabs with onend(function() {restart()})
can crash the browser, as I've detailed in this bug report: https://code.google.com/p/chromium/issues/detail?id=296690)
See https://github.com/TalAter/annyang/blob/1ee294e2b6cb9953adb9dcccf4d3fcc7eca24c2c/src/annyang.js#L214 for how I handle this.
Don't autorestart if the reason for it ending is something like service-not-allowed
or not-allowed
See https://github.com/TalAter/annyang/blob/1ee294e2b6cb9953adb9dcccf4d3fcc7eca24c2c/src/annyang.js#L196
You can see how I handled this in my code - https://github.com/TalAter/annyang/blob/master/src/annyang.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With