react-speech-kit
react-speech-kit copied to clipboard
Failed to execute 'start' on 'SpeechRecognition': recognition has already started. at listen
The above error is coming when stopping and again listening to the microphone in useSpeechRecognition hook and there is the callback for result is not getting executed. I'm getting it even when using the examples provided in the docs. I'm on Microsoft Edge Version 81.0.416.64
I can reproduce the error and will take a closer look later today. It looks like support for SpeechRecognition on edge is pretty new and others have reported buggy behaviour even on Edge Canary 84.0.488.0. https://techcommunity.microsoft.com/t5/discussions/web-speech-api-support/m-p/1104645
Unfortunately this appears to be a bug with Edge's implementation of the SpeechRecognition api. The following minimal example without react-speech-kit throws the same error.
const recognition = new window.webkitSpeechRecognition();
recognition.onstart = () => { console.log('started'); }
recognition.onend = () => { console.log('ended'); }
recognition.onresult = (e) => { console.log('result', e); }
recognition.start();
// 'started' is logged but onresult is not triggered as you speak
recognition.stop();
// 'ended' is not logged indicating that recognition hasn't been stopped properly
recognition.start();
// Uncaught DOMException: Failed to execute 'start' on 'SpeechRecognition': recognition has already started.