Speech Recognition

The speech recognition part of the Web Speech API allows authorized web applications to access the device's microphone and produces a transcript of the voice being recorded. This allows web applications to use voice as one of the input & control method, similar to touch or keyboard.

Technically, the speech recognition functionality can also be achieved by accessing the microphone and processing the audio stream using Web Audio API. An examplary library that takes such an approach is pocketsphinx.js.

API glimpse

let recognition = new SpeechRecognition()
Creates an object used to configure the recognition process and to receive events about the recognition results.
recognition.continuous
A boolean property indicating whether the process should stop after the first final transcripts received (when false, the default) or send multiple events, until the process is explicitly stopped (when true).
recognition.interimResults
A boolean property indicating whether interim (not-yet-final) transcripts should be provided, false by default.
recognition.lang
A property to set up the language for the recognition.
recognition.addEventListener('result', listener)
An event fired when the process has produced the transcripts for the piece of audio recorded. The listener is called with an array of results, each containing a boolean final flag indicating whether the result might be updated in the future event (when false) or not and the collection of alternative transcripts, each with transcript itself and a confidence value.
recognition.addEventListener('nomatch', listener)
An event fired when the process has not produced any transcripts for the piece of audio recorded with the confidence exceeding the minimal threshold, i.e. it is not possible to provide the transcription.
recognition.start()
Starts the recognition process.
recognition.stop()
Stops the recognition process; useful when recognition.continuous is set to true.

Resources