Skip to content Skip to sidebar Skip to footer

Speech Recognition API In Microsoft Edge (Not Defined)

I have been attempting to use the SpeechRecognition API(https://wicg.github.io/speech-api/#examples-recognition) in a recent project. I am currently using the browser Microsoft edg

Solution 1:

As of 6/4/2020 Edge Chromium does not really support the Speech Recognition part of the Web Speech API. Microsoft seems to be working on it for Edge Chromium. It will probably never work for Edge Legacy (non-Chromium).

developer.microsoft.com says incorrectly that it is "Supported" but also says, "Working draft or equivalent". (UPDATE: As of 2/18/2021 it now says: "NOT SUPPORTED")

developer.mozilla.org compatibility table also incorrectly says that it is supported in Edge.

caniuse correctly shows that it is not supported in Edge Chromium even though it acts like it is but the proper events are not fired.

The only other browsers besides Chrome and Chromium that I have seen the Speech Recognition part of the Web Speech API work with is Brave and Yandex. Yandex probably connects to a server in Russia to process the speech recognition. It does not do a good job. At least in English. At the moment Brave is returning a "Network" error. According to this github Brave discussion Brave would have to pay Google in order to get the speech to text service.

Here is some quick code that can be used to test if Speech Recognition works in a browser and display all the errors and events in the body. It only works with https protocol. It does not seem to work with codepen or jsfiddle.

var msg = document.body;
var cr = "<br />";
var event_list = ["onaudioend", "onaudiostart", "onend", "onerror", "onnomatch", "onresult", "onsoundend", "onsoundstart", "onspeechend", "onspeechstart", "onstart"];
var sr = window.SpeechRecognition || window.webkitSpeechRecognition || false;

if (sr) {
    var recognition = new sr();
    event_list.forEach(function(e) {
        recognition[e] = function() { 
            console.log(event); 
            var txt = event.type + ": ";
            if (event.results) txt += event.results[0][0].transcript;
            if (event.error) txt += event.error; // "not-allowed" usually is because of not using secure https protocol
            if (event.type == "end") 
                recognition.start(); // Start Recognition again
            msg.innerHTML += txt + cr;
        };  
    });
    recognition.start();
}
else {
    msg.innerHTML += "This browser does not support SpeechRecognition or webkitSpeechRecognition." + cr;
}

Post a Comment for "Speech Recognition API In Microsoft Edge (Not Defined)"