这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
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:
SpeechRecognition
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
object, which has a number of event handlers available for detecting when speech is input through the device's microphone. The
SpeechGrammar
interface represents a container for a particular set of grammar that your app should recognise. Grammar is defined using
JSpeech Grammar Format
(
JSGF
)。
SpeechSynthesis
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
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()
方法。
For more details on using these features, see Using the Web Speech API .
SpeechRecognition
SpeechRecognitionEvent
sent from the recognition service.
SpeechRecognitionAlternative
Represents a single word that has been recognised by the speech recognition service.
SpeechRecognitionError
Represents error messages from the recognition service.
SpeechRecognitionEvent
result
and
nomatch
events, and contains all the data associated with an interim or final speech recognition result.
SpeechGrammar
The words or patterns of words that we want the recognition service to recognize.
SpeechGrammarList
SpeechGrammar
对象。
SpeechRecognitionResult
SpeechRecognitionAlternative
对象。
SpeechRecognitionResultList
SpeechRecognitionResult
objects, or a single one if results are being captured in
continuous
模式。
SpeechSynthesis
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.
SpeechSynthesisErrorEvent
SpeechSynthesisUtterance
objects in the speech service.
SpeechSynthesisEvent
SpeechSynthesisUtterance
objects that have been processed in the speech service.
SpeechSynthesisUtterance
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.)
SpeechSynthesisVoice
SpeechSynthesisVoice
has its own relative speech service including information about language, name and URI.
Window.speechSynthesis
[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.
Web Speech API repo on GitHub contains demos to illustrate speech recognition and synthesis.
| 规范 | 状态 | 注释 |
|---|---|---|
| Web 语音 API | 草案 | 初始定义 |
SpeechRecognition
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
SpeechRecognition
|
Chrome
33
Prefixed
注意事项
|
Edge
≤79
Prefixed
注意事项
|
Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No |
WebView Android
4.4.3
Prefixed
注意事项
|
Chrome Android
33
Prefixed
注意事项
|
Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No |
Samsung Internet Android
2.0
Prefixed
注意事项
|
完整支持
不支持
实验。期望将来行为有所改变。
见实现注意事项。
要求使用供应商前缀或不同名称。
SpeechSynthesis
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
SpeechSynthesis
|
Chrome 33 | Edge ≤18 | Firefox 49 | IE 不支持 No | Opera 21 | Safari 7 | WebView Android 4.4.3 | Chrome Android 33 | Firefox Android 62 | Opera Android 不支持 No | Safari iOS 7 | Samsung Internet Android 3.0 |
完整支持
不支持
实验。期望将来行为有所改变。
用户必须明确启用此特征。