SpeechRecognition: Phương thức abort()

Khả dụng hạn chế

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

Phương thức abort() của Web Speech API dừng dịch vụ nhận dạng giọng nói không nghe audio đến, và không cố gắng trả về SpeechRecognitionResult.

Cú pháp

js
abort()

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(".start");
const abortBtn = document.querySelector(".abort");

startBtn.onclick = () => {
  recognition.start();
  console.log("Ready to receive a color command.");
};

abortBtn.onclick = () => {
  recognition.abort();
  console.log("Speech recognition aborted.");
};

recognition.onspeechend = () => {
  recognition.stop();
  console.log("Speech recognition has stopped.");
};

Đặc tả kỹ thuật

Thông số kỹ thuật
Web Speech API
# dom-speechrecognition-abort

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

Xem thêm