1

I have a following problem:

I create a grammar string out of lyrics on a song. Then I set up (webkit)SpeechRecognition grammar like:

const grammars = new SpeechGrammarList();
grammars.addFromString(grammarString, 1);

const config = {
  lang: 'en-US',
  interimResults: true,
  maxAlternatives: 0,
  continuous: true,
  grammars,
  onresult,
};

const recognition = new SpeechRecognition();
Object.entries(config).forEach(([key, val]) => (recognition[key] = val));

After setting it up, recognition.grammars.src returns (I decoded this from the original format):

data:application/xml,#JSGF V1.0; grammar lyrics; public <lyric> = look | if | you | had | one | shot | or | opportunity | to | seize | everything | ever | wanted | in | moment | would | capture | it | just | let | slip ; (you may recognize the song ;))

So everything should be ok, according to that result.

But since I'm not a native speaker, and when I start by saying "look" - it'll return "Luke" with "high confidence" at least 25% of time.

Now I'm confused. Isn't the purpose of the grammar to primarily emphasise words (and phrases) it contains?


Actual Question: What is the best advice to achieve correct grammar? Can I succeed without using 3rd party services?

Samuli Hakoniemi
  • 18,740
  • 1
  • 61
  • 74

0 Answers0