SpeechRecognitionEvent: resultIndex property

Limited availability

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

The resultIndex read-only property of the SpeechRecognitionEvent interface returns the lowest index value result in the SpeechRecognitionResultList "array" that has actually changed.

The SpeechRecognitionResultList object is not an array, but it has a getter that allows it to be accessed by array syntax.

Value

A number.

Examples

js
recognition.onresult = (event) => {
  const color = event.results[0][0].transcript;
  diagnostic.textContent = `Result received: ${color}.`;
  bg.style.backgroundColor = color;
  console.log(event.resultIndex); // returns 0 if there is only one result
};

Specifications

Specification
Web Speech API
# dom-speechrecognitionevent-resultindex

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
resultIndex

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

See also