0

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

trahloff
  • 607
  • 1
  • 9
  • 17

1 Answers1

1

You need to run/access your site over SSL.

Another way would be to run the script with the speech-recognition in a Chrome Extension.

Chrome will always ask when the microphone is accessed.

PS: I would test it on the Cordova target platforms, before continuing -- the webspeech-recognition might not be available on all/any of those platforms (maybe with crosswalk...)

redrockzee
  • 485
  • 6
  • 7
russa
  • 399
  • 3
  • 7