Avatar of codefinger
codefinger
Flag for United States of America asked on

How to list the values in Speech.Recognition.Choices?

In my vb.net winforms voice enabled app, I want to display to the user a list of available commands. By available, I mean the commands the speech engine is supposed to recognize.  In my app there will be a limited set of about 50 or so.

( I know what commands are SUPPOSED to be there because my code added them to a supposedly empty grammar. In addition to helping the user, actually querying the engine will validate that it contains what it is supposed to contain.)

How do I pull the current values from the Speech.Recognition.Choices?

In debug mode, this works to return the items one at a time (zero is an example element).

DirectCast(sc.ValidCommands.OneOf.items(0),System.Speech.Internal.GrammarBuilding.GrammarBuilderPhrase).DebugSummary

But the same code is not recognized by my winforms app when I try to add it.  It will not compile because it says Oneof is not a member of Speech.Recognition.Choices and  System.Speech.Internal.GrammarBuilding.GrammarBuilderPhrase is not defined.

(Windows XP, Speech SDK 5.1, Net Framework 4.)


Any help appreciated.  

Thanks in advance.
Microsoft DevelopmentVoice Recognition.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
codefinger

8/22/2022 - Mon
TommySzalapski

Can't you just do something like this?
For Each choice In Speech.Recognition.Choices
MsgBox choice.ToString
Next
codefinger

ASKER
Tommy:

Nope.   There is no such thing as a single Speech.Recognition.Choice.
Mike Tomlinson

This will supposedly build a treeview from all the loaded grammars:
http://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognizer.grammars(VS.85).aspx
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
codefinger

ASKER
I only load one grammar at a time, unloading them all between (which now that I think about it, is kind of inefficient, but that is a problem for another day...).   I don't think the code Idle_Mind sent me to will show me the individual phrases inside the grammer...when I debug, all I can find for RuleName inside my grammer is "root".

I think what I need is GrammerBuilder.DebugShowPhrases, but that item is not recognized by the intellisense, even though it is referred to in some of the MSDN pages I was just reading.  Maybe I am missing a reference?
TommySzalapski

I'll set up a test project later today after my son's doctor's appointment and try to figure it out that way if no one gets it solved by then.
codefinger

ASKER
Hey Tommy, any luck?  (EE is saying this is an inactive question.)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Bob Learned

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
codefinger

ASKER
I almost dismissed this answer because "DebugShowPhrases" does NOT show up in the VBE intellisense...but I decided to type it in anyway and to my surprise, VBE did not object and it compiled!  

This gave me EXACTLY what I was seeking.   Thanks!
Bob Learned

Did you have the All selection for the Intellisense, or the Common?  Sometimes Intellisense doesn't show, but as you found out, you can still reference it, since the compiler uses a different technique to evaluate tokens.

Maybe I saw it, because I use C#, which is a different development environment than VB.NET.
codefinger

ASKER
I use Visual Studio Express 2010, which may not have an option to modify the way the intellisense works, or it may, but I am not sure where to look....
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Bob Learned

You get Intellisense as it is, but you can see how there are two options for viewing (Common and All):




Snapshot.png
codefinger

ASKER

I had never noticed those tabs before!  
(But FYI, DebugShowPhrases does not show up in VSE 2010 in the intellisense under
either tab.)

More good stuff to know, though!
Thanks for the additional info!
codefinger

ASKER
TheLearnedOne:

Clearly, you know your way around voice recognition.

Can you check out this related question please?

https://www.experts-exchange.com/questions/26884116/resetting-recognition-engine-to-fewer-phrases.html
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.