SpeechRecognition: Sự kiện soundend

Limited availability

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

Sự kiện soundend của Web Speech API được kích hoạt khi bất kỳ âm thanh nào — giọng nói có thể nhận dạng hay không — ngừng được phát hiện.

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("soundend", (event) => { })

onsoundend = (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 soundend trong phương thức addEventListener:

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

recognition.addEventListener("soundend", (event) => {
  console.log("Sound has stopped being received");
});

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

js
recognition.onsoundend = (event) => {
  console.log("Sound has stopped being received");
};

Đặc tả kỹ thuật

Specification
Web Speech API
# eventdef-speechrecognition-soundend
Web Speech API
# dom-speechrecognition-onsoundend

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

Xem thêm