SpeechRecognition: Phương thức stop()
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Phương thức stop() của Web Speech API dừng dịch vụ nhận dạng giọng nói không nghe audio đến và cố gắng trả về SpeechRecognitionResult dựa trên các kết quả đã ghi nhận được cho đến thời điểm đó.
Cú pháp
js
stop()
Tham số
Không có.
Giá trị trả về
Không có (undefined).
Ví dụ
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.");
};
Đặc tả kỹ thuật
| Specification |
|---|
| Web Speech API> # dom-speechrecognition-stop> |