javascript - Web Speech API 自定义词

标签 javascript html speech-recognition w3c speech-to-text

我通读了 W3C docs对此,我认为自定义词来自自定义语法,但我尝试转到 this demo并在控制台中输入以下 javascript:

recognition.grammars.addFromString('foo');

运行良好,recognition.grammars[0].src 返回:"data:application/xml,foo"

注意:'foo'不是我感兴趣的词,但我感兴趣的词不是英语词,以'foo'为例。当我正常说我的习惯词时,它认为我在说别的东西(这是有道理的)。我在这里使用“foo”来保护我的品牌:)

所以我想要的是能够说“Hey, foo”,类似于“Ok, Google”的工作方式。但是我的“foo”字不是一个实际的字,所以 SpeechRecognitionResult 没有我的自定义字。

我是否误解了如何添加自定义词,或者这在今天是不可能的?

最佳答案

When I speak my custom word normally, it thinks I'm saying something else (which makes sense).

Google 在不支持语法的情况下提供非常有限的语音 API 实现,请参阅相关问题:

Grammar in Google speech API

此外,就语法及其处理而言,即使是原始规范也不完整。

So what I want is to be able to say "Hey, foo" similar to how "Ok, Google" works. But my "foo" word is not an actual word so the SpeechRecognitionResult doesn't have my custom word.

此任务不是语音识别任务,因此无法通过语音识别引擎有效解决,它需要关键字识别,因为它需要过滤除您的关键字之外的所有语音。

您可以尝试使用 Pocketsphinx javascript 库 ( http://cmusphinx.sourceforge.net/2013/06/voice-enable-your-website-with-cmusphinx/ ) 来实现它。使用 pocketsphinx,调试发音问题也更容易。

另见 Web Speech API - SpeechGrammar其中专门描述了对语法的支持。

关于javascript - Web Speech API 自定义词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18830438/

相关文章:

bash - 预期的音频采样率与实际不匹配?

javascript - AngularJS 不以与常规 HTML 相同的方式应用 CSS?

JavaScript Express、 Node 和 CSVtoJSON

javascript - 额外的空白包含在 angularjs 的动态下拉列表中

html - 有没有办法让这个ribbon成为纯css的ribbon?又名 : can I just add a ribbon-updated class

javascript - EaselJS透视图像变换

html - 按属性条件删除某些div

ios - iPhone 5 上的语音识别

javascript - 失败 TFS 建立在像 TC 这样的指标变化上

speech-recognition - 使用 TensorFlow 语音到文本