Continuous speech recognition using Webkit speech api

i started using this browser function (chrome). I wrote JS based on this, but the problem is that it only recognizes speech once and ends. it is not going to constantly, I need to press the button again and again to start speech recognition. tell me where i have to fine tune. I set "recognition .continuous = true" still doesn't help?

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" with a button! thats it

+4
source share
2 answers

Perhaps a typo on this line:

 recognition.continuos = true; 

Must be equal to:

 recognition.continuous = true; 
+8
source

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 β€œspeechless” error occurs (the onerror event fires), and the engine turns off. I just added the code to onend to restart the engine:

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

The next problem you may get is that every time the engine restarts, the user must re-grant permission so that the browser uses the microphone. The only solution at this time seems to be to make sure you are connecting to your site via HTTPS (source: http://updates.html5rocks.com/2013/01/Voice-Driven-Web-Apps-Introduction- to-the-Web-Speech-API bottom of the message in bold)

+7
source

Source: https://habr.com/ru/post/1485654/


All Articles