SpeechRecognitionEvent

Khả dụng hạn chế

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

Giao diện SpeechRecognitionEvent của Web Speech API đại diện cho đối tượng sự kiện cho các sự kiện resultnomatch, và chứa tất cả dữ liệu liên quan đến kết quả nhận dạng giọng nói tạm thời hoặc cuối cùng.

Event SpeechRecognitionEvent

Hàm khởi tạo

SpeechRecognitionEvent()

Tạo đối tượng SpeechRecognitionEvent mới.

Thuộc tính phiên bản

SpeechRecognitionEvent cũng kế thừa các thuộc tính từ giao diện cha Event.

SpeechRecognitionEvent.resultIndex Read only

Trả về giá trị chỉ số kết quả thấp nhất trong "mảng" SpeechRecognitionResultList đã thực sự thay đổi.

SpeechRecognitionEvent.results Read only

Trả về đối tượng SpeechRecognitionResultList đại diện cho tất cả kết quả nhận dạng giọng nói cho phiên hiện tại.

Ví dụ

Mã này được trích xuất 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 = `Result received: ${color}.`;
  bg.style.backgroundColor = color;
};

Thông số kỹ thuật

Thông số kỹ thuật
Web Speech API
# speechreco-event

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

Xem thêm