SpeechRecognition:stop() 方法
stop() 方法屬於 Web Speech API,它會停止語音識別服務監聽傳入音訊,並嘗試返回一個基於到目前為止捕獲結果的 SpeechRecognitionResult。
語法
js
stop()
引數
無。
返回值
無(undefined)。
示例
js
const recognition = new SpeechRecognition();
const diagnostic = document.querySelector(".output");
const bg = document.querySelector("html");
const startBtn = document.querySelector("button");
startBtn.onclick = () => {
recognition.start();
console.log("Ready to receive a color command.");
};
recognition.onspeechend = () => {
recognition.stop();
console.log("Speech recognition has stopped.");
};
規範
| 規範 |
|---|
| Web Speech API # dom-speechrecognition-stop |
瀏覽器相容性
載入中…