SpeechRecognitionResultList: thuộc tính length

Limited availability

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

Thuộc tính chỉ đọc length của giao diện SpeechRecognitionResultList trả về độ dài của "mảng" — số lượng đối tượng SpeechRecognitionResult trong danh sách.

Giá trị

Một số.

Ví dụ

Code này được trích từ ví dụ Speech color changer của chúng tôi.

js
recognition.onresult = (event) => {
  const color = event.results[0][0].transcript;
  diagnostic.textContent = `Nhận được kết quả: ${color}.`;
  bg.style.backgroundColor = color;

  console.log(event.results.length);
};

Thông số kỹ thuật

Specification
Web Speech API
# dom-speechrecognitionresultlist-length

Tương thích trình duyệt

Xem thêm