files/en-us/web/api/speechrecognition/error_event/index.md
{{APIRef("Web Speech API")}}
The error event of the Web Speech API {{domxref("SpeechRecognition")}} object is fired when a speech recognition error occurs.
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
addEventListener("error", (event) => { })
onerror = (event) => { }
A {{domxref("SpeechRecognitionErrorEvent")}}. Inherits from {{domxref("Event")}}.
{{InheritanceDiagram("SpeechRecognitionErrorEvent")}}
In addition to the properties listed below, properties from the parent interface, {{domxref("Event")}}, are available.
You can use the error event in an addEventListener method:
const recognition = new (SpeechRecognition || webkitSpeechRecognition)();
recognition.addEventListener("error", (event) => {
console.error(`Speech recognition error detected: ${event.error}`);
});
Or use the onerror event handler property:
recognition.onerror = (event) => {
console.error(`Speech recognition error detected: ${event.error}`);
};
{{Specifications}}
{{Compat}}