The error read-only property of the SpeechRecognitionErrorEvent interface returns the type of error raised.
An enumerated value representing the type of error. Possible values include:
abortedSpeech input was aborted in some manner, perhaps by some user-agent-specific behavior like a button the user can press to cancel speech input.
audio-captureAudio capture failed.
bad-grammar There was an error in the speech recognition grammar or semantic tags, or the chosen grammar format or semantic tag format was unsupported.
Note: This error is no longer part of the Web Speech API specification; the concept of grammar has been removed from the Web Speech API. Related features remain in the specification and are still recognized by supporting browsers for backwards compatibility, but they have no effect on speech recognition services.
language-not-supportedThe user agent does not support the language specified in the lang attribute of the SpeechRecognition object. The set of supported languages is browser-dependent, and there is no way to programmatically determine from front-end code the languages a user's browser supports for speech recognition.
networkNetwork communication required for completing the recognition failed.
no-speechNo speech was detected.
not-allowedThe user agent disallowed any speech input from occurring for reasons of security, privacy or user preference.
phrases-not-supportedThe speech recognition model does not support phrases for contextual biasing.
service-not-allowedThe user agent disallowed the requested speech recognition service, either because the user agent doesn't support it or because of reasons of security, privacy or user preference. In this case it would allow another more suitable speech recognition service to be used instead.
const recognition = new SpeechRecognition();
recognition.onerror = (event) => {
console.log(`Speech recognition error detected: ${event.error}`);
console.log(`Additional information: ${event.message}`);
};