html - 如何通过 HTML5 Speech Input API 在 Chrome 上通过代码启动语音识别?

标签 html google-chrome speech-recognition voice voice-recognition

我有以下代码:

<!DOCTYPE html>
<meta charset="utf-8">
<title>A HTML Document</title>
<input x-webkit-speech speech><button>Start to recognize voice</button>

如果您在 Chrome 上点击文本框中的麦克风图标,语音识别就会启动。

这就是我想要的:

当我点击按钮元素时,文本框的语音识别开始。

我尝试了 startSpeechInput(http://lists.w3.org/Archives/Public/public-xg-htmlspeech/2011Feb/att-0020/api-draft.html)、SpeechReco(http://lists.w3.org/Archives/Public/public-webapps/2011OctDec/att-1696/speechapi.html#examples)和 SpeechInputRequest(http://lists.w3.org/Archives/Public/public-xg-htmlspeech/2011Sep/0033.html),它们都不能在 Chrome 上运行。

我怎样才能做到这一点?

HTML5 Speech Input API 由 Google 提交。除了 Chrome 之外,没有浏览器实现这个 HTML5 规范。现在 HTML5 规范中引入了 3 种方法。但它们都不是由谷歌实现的。我觉得 HTML5 只是谷歌自己的游戏。 Google 应严格执行 HTML5 规范。

最佳答案

您无法使用 javascript 真正管理 x-webkit-speech 输入。顺便说一句,这个功能以后会被弃用,你可以看看this link .

现在您必须使用 Web Speech API。该 API 是 google 在 W3C 列表上提出的非官方草案。目前,在 HTML5 的 W3C 规范中没有讨论添加此 API。

如果您想使用此 Web Speech API,您可以查看 this link ,有很好的解释和示例如何使用它。

关于html - 如何通过 HTML5 Speech Input API 在 Chrome 上通过代码启动语音识别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17851746/

相关文章:

html - 中心和比例输入控件

html - anchor 链接问题 |适用于 firefox 但不适用于 chrome

google-chrome - 在 Ubuntu 中为 Google Chrome 禁用 AdBlock Plus 中的首次运行页面

ios - 重启录音时 AVAudioEngine inputNode installTap 崩溃

iphone - iPhone 没有网络也能识别大词汇量语音吗?

javascript - 如何在单击时向按钮添加类

javascript - 将正方形 div 动画化为梯形

javascript - 同步事件中的 ServiceWorker 无法使用 waitUntil

java - 使用 cmu sphinx 进行语音识别 - 无法正常工作

javascript - 未捕获的 TypeError :Cannot read property indexOf. 也许是 .load() jquery 问题?