Add generic placeholders to SRGS Grammar

2019-09-02 16:33发布

问题:

I trying to add speech recognition into my app. But unfortunately I don't find a way to add generic placeholders. For example I want to say "I am looking for stackoverflow" then I use this grammar:

<grammar root="start" {...}>
  <rule id="start" scope="public">
    I am       
    <one-of>         
      <item> looking for</item>
      <item> listening to</item> 
    </one-of>
  </rule>

<!-- here could be any word -->

</grammar>

My problem is, how to implement the search for "stackoverflow". If I use this grammar the recognizer always finds "I am looking for". Great, but the important word is missing. If I am not using any grammar then I get something like "I and looking four steak overflow". Here I got the important word, but cannot use rules to constrain to "I am" and "looking for".

My need is of course "I am looking for steak overflow".

How could I achieve this? Thanks in advance!

回答1:

There is no way to recognize "any word" just because you can not define "any word" strictly. Does "fasdfewqrqew" count as a word you want to recognize? I'm sure not.

I'm sure you want to recognize a certain list of words, probably large. Then you can just list all of them in SRGS grammar. You can find a word list with frequent words here and just convert the list to the grammar.

If you want to increase the list coverage you can also put the sequence of syllables instead of the list of words in the grammar. You can extract the list of syllables from the phonetic dictionary like CMUDict from CMUSphinx project. That will give you more variations with less variants but prepare to get nonsense words in the results.