Recognize a Speech Input
Use SpeechRecognition for a simple recognition interaction. Register result and error events before starting, then stop it when the page lifecycle ends.
Complete the Example
Use SpeechRecognition for a simple recognition interaction. Register result and error events before starting, then stop it when the page lifecycle ends.
const recognition = new SpeechRecognition();
recognition.onresult = (event) => {
const best = event.results[0][0];
console.log(best.transcript, best.confidence);
};
recognition.onerror = (event) => {
console.error(event.error, event.message);
};
recognition.start();
See Speech Recognition for streamed audio and capability negotiation.