Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

continous speech recognition with Webkit speech api

i started using this browser(chrome) feature. i ve written a JS based on this , but the problem is even , it recognises the speech only once and ends . its not going continuously, i need to press the button again and again to start speech recognition . tell me where i should tweak . i ve set "recognition.continuous=true" still not helping ?

var recognition = new webkitSpeechRecognition();
recognition.continuous     = true;
recognition.interimResults = true;

recognition.onstart = function() {
  console.log("Recognition started");
};
recognition.onresult = function(event){
  console.log(event.results);
};
recognition.onerror = function(e) {
  console.log("Error");
};

recognition.onend = function() {
  console.log("Speech recognition ended");
};

function start_speech() {
  recognition.lang = 'en-IN'; // 'en-US' works too, as do many others
  recognition.start();
}

I call "start_speech" from a button ! thats it

like image 847
dineshswamyp Avatar asked Jun 11 '13 17:06

dineshswamyp


People also ask

What is WebKit speech recognition?

The HTML5 Speech Recognition API allows JavaScript to have access to a browser's audio stream and to convert it to text. I'm going to show you how to use the web speech API so that you can invite your users to talk with your current or future web application.

What is a continuous speech recognition?

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.


2 Answers

I know this is an old thread, but I had this problem too. I found that, even with the continuous flag set, if there are pauses in the input speech, a "no-speech" error gets thrown (triggers the onerror event) and the engine is shut down. I just added code in the onend to restart the engine:

recognition.onend = function() {
    recognition.start();
};

The next problem you might get is, every time the engine restarts, the user has to re-grant permission to let the browser use the microphone. The only solution at this time seems to be to make sure you connect to your site over HTTPS (source: http://updates.html5rocks.com/2013/01/Voice-Driven-Web-Apps-Introduction-to-the-Web-Speech-API bottom of post in bold)

like image 62
ultramoka Avatar answered Oct 15 '22 19:10

ultramoka


Perhaps the typo on this line:

recognition.continuos = true;

Should equal:

recognition.continuous = true;
like image 30
Tait Brown Avatar answered Oct 15 '22 20:10

Tait Brown