0

I'm currently developing a web application using the WebkitSpeechRecognition API. The problem is, that when I first initialise the API with .start() and begin yelling into my microphone, it usually takes more than 20 seconds until the first .onresult is triggered. In this meantime, I want to give feedback to the user that the tool is booting up and tell him once he can start talking. Unfortunately, onresult is only triggered if there is a speech input, not if the user patiently waits in silence for the initialisation to finish. Is there a way to check if the recognition is ready to go?

Thanks a lot.

Don_M
  • 45
  • 6

1 Answers1

0

set continuous to false on the initialization

see the below example

if ('webkitSpeechRecognition' in window) {
                var recognition = new webkitSpeechRecognition();
                recognition.continuous = false;
                recognition.interimResults = false;
                recognition.onstart = function () { $('#modalLoadText').hide(); $('#modalListenText').show(); $('#myModal').modal('show'); console.log("Start"); }
                recognition.onresult = function (event) { console.log("Finish"); }
                recognition.onerror = function (event) { console.log("Error"); }
                recognition.onend = function () { $('#modalLoadText').show(); $('#modalListenText').hide(); $('#myModal').modal('hide'); console.log("End"); }
            }