I was able to start the speech recognition on page load:
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.onresult = function(e) {
for (var i = e.resultIndex; i < e.results.length; ++i) {
if (e.results[i].isFinal) {
$scope.data += e.results[i][0].transcript;
}
}
}
// start listening
recognition.start();
I get a popup notification in my browser that asks me to allow the site to access my microphone.
When I create buttons for recognition.start();
and recognition.stop();
the notification pops up everytime the start button is pressed.
What I want is that the user is asked on pageload if he allows the site to access his microphone, the page remembers his decision and can start/stop the speech recognition without an additional popup. Is there a solution?
Edit: tested on the latest Chrome on Windows but it's a Cordova project and should ultimately run on Android/iOS