SpeechRecognition:start 事件
SpeechRecognition 物件的 start 事件在語音識別服務已開始監聽傳入的音訊,並打算識別與當前 SpeechRecognition 關聯的語法時觸發。這是 Web Speech API 的一部分。
語法
在諸如 addEventListener() 之類的方法中使用事件名稱,或設定事件處理程式屬性。
js
addEventListener("start", (event) => { })
onstart = (event) => { }
事件型別
一個通用的 Event,沒有額外的屬性。
示例
您可以使用 addEventListener 方法來處理 start 事件
js
const recognition = new (SpeechRecognition || webkitSpeechRecognition)();
recognition.addEventListener("start", () => {
console.log("Speech recognition service has started");
});
或者使用 onstart 事件處理程式屬性
js
recognition.onstart = () => {
console.log("Speech recognition service has started");
};
規範
| 規範 |
|---|
| Web Speech API # eventdef-speechrecognition-start |
| Web Speech API # dom-speechrecognition-onstart |
瀏覽器相容性
載入中…