From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/web_speech_api/index.html | 116 ++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 files/zh-cn/web/api/web_speech_api/index.html (limited to 'files/zh-cn/web/api/web_speech_api/index.html') diff --git a/files/zh-cn/web/api/web_speech_api/index.html b/files/zh-cn/web/api/web_speech_api/index.html new file mode 100644 index 0000000000..82ffea08fa --- /dev/null +++ b/files/zh-cn/web/api/web_speech_api/index.html @@ -0,0 +1,116 @@ +--- +title: Web Speech API +slug: Web/API/Web_Speech_API +tags: + - API + - 参考 + - 合成 + - 实验性的 + - 网页语音API + - 识别 + - 语音 +translation_of: Web/API/Web_Speech_API +--- +
{{DefaultAPISidebar("Web Speech API")}}{{seecompattable}}
+ +
+

Web Speech API 使您能够将语音数据合并到 Web 应用程序中。 Web Speech API 有两个部分:SpeechSynthesis 语音合成 (文本到语音 TTS)和 SpeechRecognition  语音识别(异步语音识别)。

+
+ +

Web Speech 的概念及用法

+ +

Web Speech API 使 Web 应用能够处理语音数据,该项 API 包含以下两个部分:

+ + + +

更多关于这些特性的细节请参考 Using the Web Speech API

+ +

Web Speech 的 API 接口

+ +

 语音识别

+ +
+
{{domxref("SpeechRecognition")}}
+
语音识别服务的控制器接口;它也处理由语音识别服务发来的 {{domxref("SpeechRecognitionEvent")}} 事件。
+
{{domxref("SpeechRecognitionAlternative")}}
+
表示由语音识别服务识别出的一个词汇。
+
{{domxref("SpeechRecognitionError")}}
+
表示语音识别服务发出的报错信息。
+
{{domxref("SpeechRecognitionEvent")}}
+
{{event("result")}} 和 {{event("nomatch")}} 的事件对象,包含了与语音识别过程中间或最终结果相关的全部数据。
+
{{domxref("SpeechGrammar")}}
+
我们将要交由语音识别服务进行识别的词汇或者词汇的模式。
+
{{domxref("SpeechGrammarList")}}
+
表示一个由 {{domxref("SpeechGrammar")}} 对象构成的列表。
+
{{domxref("SpeechRecognitionResult")}}
+
表示一次识别中的匹配项,其中可能包含多个 {{domxref("SpeechRecognitionAlternative")}} 对象。
+
{{domxref("SpeechRecognitionResultList")}}
+
表示包含 {{domxref("SpeechRecognitionResult")}} 对象的一个列表,如果是以 {{domxref("SpeechRecognition.continuous","continuous")}} 模式捕获的结果,则是单个对象。
+
+ +

语音合成

+ +
+
{{domxref("SpeechSynthesis")}}
+
语音合成服务的控制器接口,可用于获取设备上可用的合成语音,开始、暂停以及其它相关命令的信息。
+
{{domxref("SpeechSynthesisErrorEvent")}}
+
包含了在发音服务处理 {{domxref("SpeechSynthesisUtterance")}} 对象过程中的信息及报错信息。
+
{{domxref("SpeechSynthesisEvent")}}
+
包含了经由发音服务处理过的 {{domxref("SpeechSynthesisUtterance")}} 对象当前状态的信息。
+
{{domxref("SpeechSynthesisUtterance")}}
+
表示一次发音请求。其中包含了将由语音服务朗读的内容,以及如何朗读它(例如:语种、音高、音量)。
+
+ +
+
{{domxref("SpeechSynthesisVoice")}}
+
表示系统提供的一个声音。每个 SpeechSynthesisVoice 都有与之相关的发音服务,包括了语种、名称 和 URI 等信息。
+
{{domxref("Window.speechSynthesis")}}
+
由规格文档指定的,被称为 SpeechSynthesisGetter 的 [NoInterfaceObject] 接口的一部分,在 Window 对象中实现,speechSynthesis 属性可用于访问 {{domxref("SpeechSynthesis")}} 控制器,从而获取语音合成功能的入口。
+
+ +

示例

+ +

GitHub 上的 Web Speech API repo 的示例程序展示了语音识别及合成。

+ +

规范

+ + + + + + + + + + + + + + +
规范状态描述
{{SpecName('Web Speech API')}}{{Spec2('Web Speech API')}}原始定义
+ +

浏览器兼容性

+ +

语音识别

+ + + +
{{Compat("api.SpeechRecognition", 0)}}
+ +

语音合成

+ +
{{Compat("api.SpeechSynthesis", 0)}}
+ + + +

相关链接

+ + -- cgit v1.2.3-54-g00ecf