Click here to Skip to main content
15,867,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a working C# Windows 11 app that uses the NuGet package System.Speech for recognition. But my code only specifies grammars containing specific words and phrases to do the things I want it to do.

I would like to specify a grammar that includes specific leading words and then an open-ended placeholder to recognize whatever else the user speaks. For example, I want to specify a grammar for utterances like "My name is" <placeholder>.

I know that I can load an entire DictationGrammar() to get the entire Windows Speech dictionary (and maybe it would recognize "my name is Joe" okay).

But is there a way to constrain the grammar to force recognition of my leading keywords "my name is" and then use an open-ended expression to recognize whatever else the user says? Thank you

What I have tried:

I wrote a working program and have spent hours searching the online documentation, but I cannot find an example that mixes some fixed words at the front of a grammar phrase and an open-ended expression at the end of the grammatical phrase.
Posted
Updated 27-May-22 11:14am
Comments
[no name] 27-May-22 13:08pm    
In the same way people say "can you repeat that", you need to "show" people what you're app is "hearing"; then they can correct it themselves, and the app "learns".

Anything else, that's what the "paid" cloud services are for (with the cycles and sampled data behind it).

1 solution

I was trying to figure out a way to do what Dragon Naturally Speaking has done for years, where you can define matching strings of the form "my keywords here <dictation>". Dragon matches your command on the first (specified) words and passes in whatever other words users speak as "dictation" in a variable called ListVar1. Then programmatically, your script can look at the text that Dragon stored in the ListVar1 variable. But nothing I have read in the Microsoft doc talks about a dictation variable.

Eventually, I found the answer. When you build your grammar with the grammar builder method, you can add a term with 'Add.DictationClass' (can't remember the exact syntax) to include an open-ended, free-form dictation clause in the grammar that you're building. You can see it with Intellisense in Visual Studio.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900