SpeechRecognitionEvent: thuộc tính resultIndex
Khả dụng hạn chế
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Thuộc tính chỉ đọc resultIndex của giao diện SpeechRecognitionEvent trả về giá trị chỉ số kết quả thấp nhất trong "mảng" SpeechRecognitionResultList đã thực sự thay đổi.
Đối tượng SpeechRecognitionResultList không phải là mảng, nhưng nó có getter cho phép truy cập bằng cú pháp mảng.
Giá trị
Một số.
Ví dụ
js
recognition.onresult = (event) => {
const color = event.results[0][0].transcript;
diagnostic.textContent = `Result received: ${color}.`;
bg.style.backgroundColor = color;
console.log(event.resultIndex); // trả về 0 nếu chỉ có một kết quả
};
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Web Speech API> # dom-speechrecognitionevent-resultindex> |