SpeechRecognition: abort()-Methode
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Die abort()
-Methode der Web Speech API stoppt den Spracherkennungsdienst, sodass er nicht mehr auf eingehende Audiodaten hört, und versucht nicht, ein SpeechRecognitionResult
zurückzugeben.
Syntax
js
abort()
Parameter
Keine.
Rückgabewert
Keiner (undefined
).
Beispiele
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.");
};
Spezifikationen
Specification |
---|
Web Speech API> # dom-speechrecognition-abort> |
Browser-Kompatibilität
Loading…