SpeechRecognition: Sự kiện audiostart

Limited availability

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

Sự kiện audiostart của Web Speech API được kích hoạt khi tác nhân người dùng bắt đầu ghi âm thanh cho nhận dạng giọng 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("audiostart", (event) => { })

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

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

recognition.addEventListener("audiostart", () => {
  console.log("Audio capturing started");
});

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

js
recognition.onaudiostart = () => {
  console.log("Audio capturing started");
};

Đặc tả kỹ thuật

Specification
Web Speech API
# eventdef-speechrecognition-audiostart
Web Speech API
# dom-speechrecognition-onaudiostart

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

Xem thêm