Search code examples
c#speech-recognitionsapi

How do you limit the words in a DictationGrammar object?


I'm trying to make an AI system using Microsoft's SAPI.

Using the DictationGrammar class returns stupid results when trying to interpret speech.

Using the GrammarBuilder class requires a Choice class (correct me here if I'm wrong) and the recognising will stop after one word.

This is unacceptable since the DictationGrammar class will not return the correct interpreted speech almost 100% of the time and putting the custom grammar in a loop takes too long and the user has to wait 5 seconds after each word.

Is there a way to make a custom grammar that will accept multiple words and not stopping after one word or specifying words to recognise in the DictationGrammar class?


Solution

  • Consider the following constructors:

    This creates a grammar for a string of words, not all of which need to be present.

    This creates a grammar for a repeated group of items.

    This creates a choice between alternate grammars.

    Also consider these methods:

    These methods add items to an existing GrammarBuilder/Choices element.