When react-speech-recognition first starts to listen, the browser will usually ask the user whether they give permission for the microphone to be used. If they deny access, react-speech-recognition did not previously handle this well:
For native browser implementations of the Web Speech API, it would be unaware that permission hadn't been given and indicate to consumers that the microphone was listening
For polyfills that throw errors when attempting to start listening in such a case, the error was not being caught, resulting in consumer apps crashing
This PR introduces a new state: isMicrophoneAvailable. If the user denies access to the microphone, the value of this will change to false. This applies in both of the following cases:
On-spec case: where the recognition object passes an error object with value { error: 'not-allowed' } to its onerror callback
Off-spec case: for polyfills that don't implement onerror but instead just throw an error from their start method
After this PR, consumers can use this library with greater confidence that their apps will continue to function even when the user denies microphone access, and have the ability to render fallback content in such a case.
When
react-speech-recognition
first starts to listen, the browser will usually ask the user whether they give permission for the microphone to be used. If they deny access,react-speech-recognition
did not previously handle this well:This PR introduces a new state:
isMicrophoneAvailable
. If the user denies access to the microphone, the value of this will change tofalse
. This applies in both of the following cases:{ error: 'not-allowed' }
to itsonerror
callbackonerror
but instead just throw an error from theirstart
methodAfter this PR, consumers can use this library with greater confidence that their apps will continue to function even when the user denies microphone access, and have the ability to render fallback content in such a case.