SpeechRecognitionEvent: resultIndex 属性
SpeechRecognitionEvent
接口的 resultIndex
只读属性返回在 SpeechRecognitionResultList
“数组”中实际发生变化的最低索引值结果。
SpeechRecognitionResultList
对象不是一个数组,但它有一个 getter,允许通过数组语法访问它。
值
一个数字。
示例
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 |
浏览器兼容性
加载中…