The SpeechRecognitionEvent() constructor creates a new SpeechRecognitionEvent object instance.
new SpeechRecognitionEvent(type, init)typeA string containing the name of the event. This will be result or nomatch, depending on the event that created the instance.
initAn initialization object that contains the following properties:
resultIndex OptionalA number representing the lowest index value result in the SpeechRecognitionResultList instance that has actually changed.
resultsA SpeechRecognitionResultList object representing all the speech recognition results returned in the associated event.
You would be unlikely to construct a SpeechRecognitionEvent instance manually. Such instances are available as event objects inside result and nomatch 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}`);
});