SpeechRecognition: Sự kiện end

Limited availability

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

Sự kiện end của đối tượng SpeechRecognition trong Web Speech API được kích hoạt khi dịch vụ nhận dạng giọng nói đã ngắt kết nối.

Cú pháp

Sử dụng tên sự kiện trong các phương thức như addEventListener(), hoặc thiết lập một thuộc tính trình xử lý sự kiện.

js
addEventListener("end", (event) => { })

onend = (event) => { }

Loại sự kiện

Một Event chung chung không có thuộc tính bổ sung.

Ví dụ

Bạn có thể sử dụng sự kiện end trong phương thức addEventListener:

js
const recognition = new (SpeechRecognition || webkitSpeechRecognition)();

recognition.addEventListener("end", () => {
  console.log("Speech recognition service disconnected");
});

Hoặc sử dụng thuộc tính trình xử lý sự kiện onend:

js
recognition.onend = () => {
  console.log("Speech recognition service disconnected");
};

Đặc tả kỹ thuật

Specification
Web Speech API
# eventdef-speechrecognition-end
Web Speech API
# dom-speechrecognition-onend

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

Xem thêm