SpeechRecognition: error event

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Want more browser support for this feature? Tell us why.

The error event of the Web Speech API SpeechRecognition object is fired when a speech recognition error occurs.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("error", (event) => { })

onerror = (event) => { }

Event type

A SpeechRecognitionErrorEvent. Inherits from Event.

Event SpeechRecognitionErrorEvent

Examples

You can use the error event in an addEventListener method:

js
const recognition = new (SpeechRecognition || webkitSpeechRecognition)();

recognition.addEventListener("error", (event) => {
  console.error(`Speech recognition error detected: ${event.error}`);
});

Or use the onerror event handler property:

js
recognition.onerror = (event) => {
  console.error(`Speech recognition error detected: ${event.error}`);
};

Specifications

Specification
Web Speech API
# eventdef-speechrecognition-error
Web Speech API
# dom-speechrecognition-onerror

Browser compatibility

See also