Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-03-03
15
Medium Priority
?
1,128 Views
Last Modified: 2013-12-04
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.
0
Comment
Question by:codefinger
  • 7
  • 3
  • 2
  • +1
15 Comments
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 35033531
Can't you just do something like this?
For Each choice In Speech.Recognition.Choices
MsgBox choice.ToString
Next
0
 

Author Comment

by:codefinger
ID: 35033696
Tommy:

Nope.   There is no such thing as a single Speech.Recognition.Choice.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 35033815
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
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

Author Comment

by:codefinger
ID: 35033902
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?
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 35038740
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.
0
 

Author Comment

by:codefinger
ID: 35059919
Hey Tommy, any luck?  (EE is saying this is an inactive question.)
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 35118308
I need to understand your context...

1) Is "sc" an instance of "Choices"?

2) Do you have a Choices.ToGrammarBuilder method?

3) If you have ToGrammarBuilder, you should be able to access the DebugShowPhrases like this:

choices.ToGrammarBuilder().DebugShowPhrases

Open in new window

0
 

Author Closing Comment

by:codefinger
ID: 35122617
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!
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 35122725
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.
0
 

Author Comment

by:codefinger
ID: 35123161
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....
0
 
LVL 96

Expert Comment

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




Snapshot.png
0
 

Author Comment

by:codefinger
ID: 35123925

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!
0
 

Author Comment

by:codefinger
ID: 35125048
TheLearnedOne:

Clearly, you know your way around voice recognition.

Can you check out this related question please?

http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_26884116.html
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question