我有以下代码:
<!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/