Web Speech API
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 makes web apps able to handle voice data. There are two components to this API:
- Speech recognition is accessed via the
SpeechRecognition(en-US) interface, which provides the ability to recognize voice context from an audio input (normally via the device's default speech recognition service) and respond appropriately. Generally you'll use the interface's constructor to create a new
SpeechRecognition(en-US) object, which has a number of event handlers available for detecting when speech is input through the device's microphone. The
SpeechGrammar(en-US) interface represents a container for a particular set of grammar that your app should recognise. Grammar is defined using JSpeech Grammar Format (JSGF.)
- Speech synthesis is accessed via the
SpeechSynthesis(en-US) interface, a text-to-speech component that allows programs to read out their text content (normally via the device's default speech synthesiser.) Different voice types are represented by
SpeechSynthesisVoice(en-US) objects, and different parts of text that you want to be spoken are represented by
SpeechSynthesisUtterance(en-US) objects. You can get these spoken by passing them to the
For more details on using these features, see Using the Web Speech API.
- The controller interface for the recognition service; this also handles the
SpeechRecognitionEvent(en-US) sent from the recognition service.
- Represents a single word that has been recognised by the speech recognition service.
- Represents error messages from the recognition service.
- The event object for the
nomatchevents, and contains all the data associated with an interim or final speech recognition result.
- The words or patterns of words that we want the recognition service to recognize.
- Represents a list of
- Represents a single recognition match, which may contain multiple
- Represents a list of
SpeechRecognitionResult(en-US) objects, or a single one if results are being captured in
- The 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.
- Contains information about any errors that occur while processing
SpeechSynthesisUtterance(en-US) objects in the speech service.
- Contains information about the current state of
SpeechSynthesisUtterance(en-US) objects that have been processed in the speech service.
- Represents 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.)
- Represents a voice that the system supports. Every
SpeechSynthesisVoicehas its own relative speech service including information about language, name and URI.
- Specced out as part of a
SpeechSynthesisGetter, and Implemented by the
speechSynthesisproperty provides access to the
SpeechSynthesis(en-US) controller, and therefore the entry point to speech synthesis functionality.
The Web Speech API repo on GitHub contains demos to illustrate speech recognition and synthesis.
|Web Speech API||Draft||Initial definition|