SpeechRecognitionErrorEvent: SpeechRecognitionErrorEvent() constructor
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The SpeechRecognitionErrorEvent() constructor creates a new
SpeechRecognitionErrorEvent object instance.
Syntax
new SpeechRecognitionErrorEvent(type, init)
Parameters
type-
A string containing the name of the event. This will always be
error. init-
An initialization object that contains the following properties:
error-
An enumerated value representing the type of error. See the possible
errorvalues. messageOptional-
A 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.
Examples
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}`);
});
Specifications
| Specification |
|---|
| Web Speech API> # dom-speechrecognitionerrorevent-speechrecognitionerrorevent> |