9

I read through the W3C docs on this and I'm thinking that custom words come from custom grammar, but I tried going to this demo and in the console entered the following javascript:

recognition.grammars.addFromString('foo');

Which ran fine and recognition.grammars[0].src returns: "data:application/xml,foo"

Note: 'foo' is not the word I'm interested in, but the word I'm interested in isn't an english word, using 'foo' for the example. When I speak my custom word normally, it thinks I'm saying something else (which makes sense). I'm using 'foo' here to protect my brand :)

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.

Am I misunderstanding how to add custom words, or is this not possible today?

2
  • Is there something you found to make it possible?
    – Nedudi
    Oct 15, 2013 at 23:19
  • 1
    @Nedudi No, I didn't find anything. But I stopped looking and just changed my requirements. It's possible there's something out there...
    – kentcdodds
    Oct 16, 2013 at 2:28

1 Answer 1

6

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

Google provides very limited implementation of speech API without support for grammars, see the question about that:

Grammar in Google speech API

Morever, even the original specification is not complete in terms of grammars and their handling.

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.

This task is not a speech recognition task so it couldn't be solved effectively by a speech recognition engine, it requires keyword spotting because it need to filter all the speech except your keyword.

You could try to implement this using Pocketsphinx javascript library (http://cmusphinx.sourceforge.net/2013/06/voice-enable-your-website-with-cmusphinx/). With pocketsphinx, it's easier to debug pronunciation issues there too.

See also Web Speech API - SpeechGrammar which specifically describes support for grammars.

3
  • Boy, that's a pretty complex library. It doesn't look either well documented or easy to use. But thanks for the link. You get the answer.
    – kentcdodds
    Sep 17, 2013 at 19:17
  • I tried the demo and wasn't really impressed. In 5 years we're going to look back at this and laugh at how rudimentary our speech recognition was.
    – kentcdodds
    Sep 18, 2013 at 1:29
  • Is this still the case in 2018? May 10, 2018 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.