The SpeechRecognitionErrorEvent() constructor creates a new SpeechRecognitionErrorEvent object instance.
new SpeechRecognitionErrorEvent(type, init)typeA string containing the name of the event. This will always be error.
initAn initialization object that contains the following properties:
errorAn enumerated value representing the type of error. See the possible error values.
message OptionalA string containing more details about the error that was raised. Note that the specification does not define the exact wording of these messages — implementers must define their own wording.
You would be unlikely to construct a SpeechRecognitionErrorEvent instance manually. Such instances are available as event objects inside error event handler functions.
For example:
const recognition = new SpeechRecognition();
recognition.addEventListener("error", (event) => {
console.log(`Speech recognition error detected: ${event.error}`);
console.log(`Additional information: ${event.message}`);
});