SpeechRecognitionEvent.resultIndex
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
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
};
仕様書
| Specification |
|---|
| Web Speech API> # dom-speechrecognitionevent-resultindex> |
ブラウザーの互換性
Loading…