Web Speech API
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.
- : A string containing the name of the event. This will always be
init- : An initialization object that contains the following properties:
error- : An enumerated value representing the type of error. See the possible
errorvalues.
- : An enumerated value representing the type of error. See the possible
message- : 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.
- : An initialization object that contains the following properties:
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
Browser compatibility
See also
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
