SpeechRecognitionEvent: SpeechRecognitionEvent() constructor
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
TheSpeechRecognitionEvent() constructor creates a newSpeechRecognitionEvent object instance.
In this article
Syntax
new SpeechRecognitionEvent(type, init)Parameters
typeA string containing the name of the event. This will be
resultornomatch, depending on the event that created the instance.initAn initialization object that contains the following properties:
resultIndexOptionalA number representing the lowest index value result in the
SpeechRecognitionResultListinstance that has actually changed.resultsA
SpeechRecognitionResultListobject representing all the speech recognition results returned in the associated event.
Examples
You would be unlikely to construct aSpeechRecognitionEvent instance manually. Such instances are available as event objects insideresult andnomatch event handler functions.
For example:
recognition.addEventListener("result", (event) => { const color = event.results[0][0].transcript; diagnostic.textContent = `Result received: ${color}.`; bg.style.backgroundColor = color; console.log(`Confidence: ${event.results[0][0].confidence}`);});Specifications
| Specification |
|---|
| Web Speech API> # dom-speechrecognition-speechrecognition> |