SpeechRecognitionEvent.resultIndex

Limited availability

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

resultIndexSpeechRecognitionEvent のインターフェイスの読み取り専用プロパティで、 SpeechRecognitionResultList 「配列」の中で最も小さな添字を結果として返します。

SpeechRecognitionResultList オブジェクトは配列ではありませんが、配列構文でアクセスできるようにゲッターがあります。

数値です。

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
};

仕様書

Specification
Web Speech API
# dom-speechrecognitionevent-resultindex

ブラウザーの互換性

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

関連情報