Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I'm trying to do a calculator using speech recognition, so it can be managed through voice. So for example, the user says "How much is 56 times 90?", the application should answer "5040". I gave a look to this: https://msdn.microsoft.com/en-us/library/office/hh538500(v=office.14).aspx[^]

It was something useful, but I did not know how to integrate it to my app (windows form). I have used the Speech namespace, but in this case, I get confused about how to use the grammar created in the msdn article.

Thanks in Advance! - CCB
Posted

1 solution

This is how:
https://msdn.microsoft.com/en-us/library/system.speech.recognition%28v=vs.110%29.aspx[^]:
https://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognizer(v=vs.110).aspx[^],
or https://msdn.microsoft.com/en-us/library/system.speech.recognition.speechrecognitionengine(v=vs.110).aspx[^].

Be careful with these two recognizers: one can work only in STA thread and another one only in MTA thread. Unfortunately, MSDN documentation keeps silence about it. This is not If this contradicts to the compatible Apartment States of the UI library you are using, you can always use a separate thread and set its Apartment State before starting it:
https://msdn.microsoft.com/en-us/library/system.threading.thread.setapartmentstate%28v=vs.110%29.aspx[^].

Another advice: the recognition fidelity is quite far from perfect. Too complex grammar can easily confuse your recognizer. So, better limit the functionality by figures, names of arithmetic operators and limited number of commands. Most complex problem I expect would be recognition of big numbers. You cannot fit too many of them in grammar. So, you may want to start with entering numbers digit by digit.

—SA
 
Share this answer
 
v3
Comments
ChrisCreateBoss 29-May-15 16:45pm    
Thanks! And yes I may keep a limit of numbers and operations, for now, I just want the 4 basic operations(+, -, *, /) and I want to add a number limit of maybe "from 0 to 1000".
Sergey Alexandrovich Kryukov 29-May-15 17:12pm    
You are very welcome.
Good luck, call again.
—SA

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