SpeechRecognitionEvent.resultIndex
利用可能性は限定的
この機能はベースラインではありません。最も広く使用されているブラウザーの一部で動作しません。
resultIndex は SpeechRecognitionEvent のインターフェイスの読み取り専用プロパティで、 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
};
仕様書
| 仕様書 |
|---|
| Web Speech API> # dom-speechrecognitionevent-resultindex> |