react-speech-kit icon indicating copy to clipboard operation
react-speech-kit copied to clipboard

Failed to execute 'start' on 'SpeechRecognition': recognition has already started. at listen

Open kushal-g opened this issue 4 years ago • 2 comments

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

kushal-g avatar Apr 28 '20 07:04 kushal-g

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

MikeyParton avatar Apr 29 '20 00:04 MikeyParton

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.

MikeyParton avatar Apr 30 '20 23:04 MikeyParton