How to automatically start Google Speech Recognition on my page?

I wrote an HTML5 webpage consisting only of:

<input type="text" style="font-size: 40px;"  name="speech" size="50"  x-webkit-speech/> 

I am trying to make x-webkit-speech start automatically as soon as I enter the page and constantly output the speech recognition results to text. How can I do it? I saw various javascripts related to this and I tested a lot of them, but they do not work for me.

Thanks to everyone who answers!;)

+4
source share
1 answer

You can try using the Web Speech API , for example:

if ('webkitSpeechRecognition' in window) {
  var recognition = new webkitSpeechRecognition();
  var final_transcript = '';
  recognition.continuous = true;
  recognition.interimResults = true;

  recognition.onresult = function( event ) {
    var final_transcript = '';
    for (var i = event.resultIndex; i < event.results.length; ++i) {
      if (event.results[i].isFinal) {
        final_transcript += event.results[i][0].transcript;
      } 
    }
    document.getElementById( 'speech' ).value = final_transcript;
  };
  recognition.start();
}

, ,

jsFiddle demo

+5

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


All Articles