The Web Speech API enables you to incorporate voice data into web apps. The Web Speech API has two parts: SpeechSynthesis (Text-to-Speech), and SpeechRecognition (Asynchronous Speech Recognition.)
The Web Speech API enables web apps to handle voice data. It has two components:
SpeechRecognition interface, which provides the ability to recognize voice context from an audio source and allows your app to respond appropriately. Generally, you use the interface's constructor to create a new SpeechRecognition object. This object provides a number of event handlers to detect when speech is incoming from the device's microphone (or from an audio track). You can specify whether you want the speech recognition to use a service provided by the user's platform (the default) or be performed locally in the browser.SpeechSynthesis interface, a text-to-speech component that allows programs to read out their text content (normally via the device's default speech synthesizer.) Different voice types are represented by SpeechSynthesisVoice objects, and different parts of text that you want to be spoken are represented by SpeechSynthesisUtterance objects. You can get these spoken by passing them to the SpeechSynthesis.speak() method.For more details on using these features, see Using the Web Speech API.
SpeechRecognitionThe controller interface for the recognition service; this also handles the SpeechRecognitionEvent sent from the recognition service.
SpeechRecognitionAlternativeRepresents a single word that has been recognized by the speech recognition service.
SpeechRecognitionErrorEventRepresents error messages from the recognition service.
SpeechRecognitionEventThe event object for the result and nomatch events, and contains all the data associated with an interim or final speech recognition result.
SpeechRecognitionPhraseRepresents a phrase that can be passed into the speech recognition engine to be used for contextual biasing.
SpeechRecognitionResultRepresents a single recognition match, which may contain multiple SpeechRecognitionAlternative objects.
SpeechRecognitionResultListRepresents a list of SpeechRecognitionResult objects, or a single one if results are being captured in continuous mode.
SpeechSynthesisThe controller interface for the speech service; this can be used to retrieve information about the synthesis voices available on the device, start and pause speech, and other commands besides.
SpeechSynthesisErrorEventContains information about any errors that occur while processing SpeechSynthesisUtterance objects in the speech service.
SpeechSynthesisEventContains information about the current state of SpeechSynthesisUtterance objects that have been processed in the speech service.
SpeechSynthesisUtteranceRepresents a speech request. It contains the content the speech service should read and information about how to read it (e.g., language, pitch and volume.)
SpeechSynthesisVoiceRepresents a voice that the system supports. Every SpeechSynthesisVoice has its own relative speech service including information about language, name and URI.
Window.speechSynthesisSpecified out as part of a [NoInterfaceObject] interface called SpeechSynthesisGetter, and Implemented by the Window object, the speechSynthesis property provides access to the SpeechSynthesis controller, and therefore the entry point to speech synthesis functionality.
The concept of grammar has been removed from the Web Speech API. Related features remain in the specification and are still recognized by supporting browsers for backwards compatibility, but they have no effect on speech recognition services.
SpeechGrammar Represents words or patterns of words for the recognition service to recognize.
SpeechGrammarList Represents a list of SpeechGrammar objects.
For information on errors reported by the Speech API (for example, "language-not-supported" and "language-unavailable"), see the following documentation:
error property of the SpeechRecognitionErrorEvent objecterror property of the SpeechSynthesisErrorEvent objectAccess to the on-device speech recognition functionality of the Web Speech API is controlled by the on-device-speech-recognition Permissions-Policy directive.
Specifically, where a defined policy blocks usage, any attempts to call the API's SpeechRecognition.available() or SpeechRecognition.install() methods will fail.
Our Web Speech API examples illustrate speech recognition and synthesis.