Description
This article provides some elementary information about how to implement Speech Recognition capabilities into your applications. The tools we would use to speech enable would be the speech SDK 5.1. Speech SDK 5.1 is the latest release in the speech product line from Microsoft. Speech SDK 5.1 can be used in various programming languages.
Introduction
Speech is one of the most natural way to interact. When it comes to computers it is no different. If an application can be controlled solely by way of voice commands then the opportunity that lies is unlimited. Even though the idea of using speech as an input mechanism for an application is not new there are not a lot of applications that use speech as in input. In other words, speech is still a big opportunity that is yet to be explored.
Microsoft speech SDK is one of the many tools that enable a developer to add speech capability into an application. Speech SDK can be used in either C#, C++, VB or any COM compliant language.
Broadly, speech can be divided in to two paradigms. Text to speech conversion and speech recognition. In this article, I shall be focusing on speech recognition conversion.
Command & Control Vs. Dictation
Speech recognition can be of two types based on the grammar that the recognition is based on. (Grammar is in other words the list of possible recognition outputs that can be generated.) An application can limit the possible combination of the words spoken by choosing proper grammar.
In a command and control scenario a developer provides a limited set of possible word combinations, and the speech recognition engine matches the words spoken by the user to the limited list. In command and control the accuracy of recognition is very high. It is always better for applications to implement command and control as the higher accuracy of recognition makes the application respond better.
In Dictation mode the recognition engine compares the input speech to the whole list of the dictionary words. For the dictation mode to have a high accuracy of recognition is it important that the user has prior trained the recognition engine by speaking in to it. The training or creating of a profile can be done by using the speech properties in the control panel.
Speech Recognition Engines
There are two different speech recognition engines, namely a Shared Recognition engine and an InProc recognition engine. A shared recognition engine can be shared across applications. This is the engine one would use when there could be multiple applications looking for speech input. A shared recognition context is recommended for most speech applications. On large speech applications that run on server alone an InProc speech recognition context is better suited.
The speech recognition engine interacts with applications using events that could be subscribed to by the application. A couple of the most important events are the recognition event and the hypothesis event. these event are raised when the engine make a good recognition or a hypothesis respectively. The code along with this article will show how to subscribe to these events.
Sample Application
The sample application with this article gives a idea to a developer on the steps one need to take in order to speech enable the menus in an application. The listing below shows a few of the important steps.
// Get an insance of RecoContext. I am using the shared RecoContext.
objRecoContext = new SpeechLib.SpSharedRecoContext();
// Assign a eventhandler for the Hypothesis Event.
objRecoContext.Hypothesis += new _ISpeechRecoContextEvents_HypothesisEventHandler(Hypo_Event);
// Assign a eventhandler for the Recognition Event.
objRecoContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(Reco_Event);
//Creating an instance of the grammer object.
grammar = objRecoContext.CreateGrammar(0);
//Activate the Menu Commands.
menuRule = grammar.Rules.Add"MenuCommands",SpeechRuleAttributes.SRATopLevel|
SpeechRuleAttributes.SRADynamic,1);
object PropValue = "";
menuRule.InitialState.AddWordTransition(null,"New"," ,SpeechGrammarWordType.SGLexical,"New", 1, ref PropValue, 1.0F );
menuRule.InitialState.AddWordTransition(null,"Open"," ",SpeechGrammarWordType.SGLexical,"Open", 2, ref PropValue, 1.0F );
//Commit the grammar rules for reco.
grammar.Rules.Commit();
grammar.CmdSetRuleState("MenuCommands", SpeechRuleState.SGDSActive);The screenshot below shows the main form of the sample application.

Summary
This article gives an introduction to speech recognition using Speech SDK 5.1.

Michael BledigPosted Nov 19, 2021, 8:02 AM EST
I notice the solution file, .sln, and Form1.designer.cs file hav not been included in the source example. Why is that? Please can those missing files be included in the example source. I would like to try and play around with the code
ANkur bhargavPosted Jun 6, 2015, 1:18 AM EDT
i Want To Create Some Speech To Text Application and this not working for me pls Help
ANkur bhargavPosted Jun 6, 2015, 1:16 AM EDT
Can Some One Help
ANkur bhargavPosted Jun 6, 2015, 1:16 AM EDT
its not working what i say
Pierre FournierPosted May 30, 2013, 6:42 AM EDT
How you set the input for microphone ?
tofaaPosted Nov 15, 2012, 10:39 PM EST
what is i need to do this on windows phone or wanna create my own library support another language like Arabic ?? how i can make the windows make voice and answer with words not in labels or texts ??
Tamas SolymosiPosted Aug 22, 2012, 12:37 AM EDT
For non-native english speakers this is absolutely useless.
laxmi lodhPosted Apr 17, 2012, 2:13 AM EDT
plz upload correct code
sathish kumarPosted Mar 8, 2012, 1:16 AM EST
this project is very useful for me. but, its showing the error on this line(objRecoContext = new SpeechLib.SpSharedRecoContext();). If you find this error, plese reply me to my id [email protected]
amarjith shivarathriPosted Jan 28, 2012, 12:34 PM EST
Could you tell me this SpeechLib works on web application, I want display user speech in textbox. please help me thanking you.
jd rjptPosted Jan 10, 2012, 4:10 AM EST
Workin Great...........
vinod sengarPosted Oct 19, 2011, 8:55 PM EDT
when i enable speech button and say new its not working ?
AnfilPosted Sep 20, 2011, 10:03 PM EDT
Good Job
aneel kumarPosted Aug 9, 2011, 12:44 AM EDT
hey dear u did a nice job.. can u tell me how can i make a voice enable browser. mean that browser will accepts the users voice command and perform that task that user wants. like if user give commnad..www.google.com then browser open that site..
samar adelPosted Aug 4, 2011, 1:47 PM EDT
plz help me in my project desktop application in c# Arabic speech recognition plz send me the source code and what is the requirements to run this application i am working in windows 7.Thanks
chethan kumarPosted Jul 26, 2011, 6:15 AM EDT
Creating an instance of the COM component with CLSID {47206204-5ECA-11D2-960F-00C04F8EE628} from the IClassFactory failed due to the following error: 8004503a. i am getting this error l u plz giv any idea to debug it
PonvelPosted Jun 20, 2011, 7:47 AM EDT
I like to get words from wav file supplied to the recognition engine based on the grammar build. Please help me if you have solution for this. Thanks in advance. S. Ponvel
aman singhPosted May 23, 2011, 11:44 PM EDT
Hello, The program is running perfectly on my system. There is only one issue with program that it is limited to 8 words only. For more words I need to add more menuRule. Is it possible that application detect all the dictionary words and based on this the word is written. Thanks
CHRISTEENA RAJANPosted Jan 3, 2011, 9:31 PM EST
hai, iam dng mi final year project in speech recognition in C# can anyone tell me the steps in hw 2 do it iam really struggling
Rakesh ThakrePosted Sep 19, 2010, 10:02 PM EDT
Suhil Srinivas is a seasoned developer, developing applications using various microsoft technologies. Suhil is a MCP and has been actively involved in mentoring and helping new-comers. He has a rich experience of building web, wireless and backend systems and has been doing consulting for various enterprises. Suhil in particular has been working a lot with the credit card and payment processing industry. EKS as a company has several products for the Educational institutes of any size. One of the chief products is the School-ERP system, which completely revolutionizes the day-to-day operation of an educational institute. Among other products EKS also has products for the small and medium healthcare providers. EKS is in to consulting and does offshore development for its customers from its office at Bangalore, India.
Thabiso MareletsaPosted Aug 11, 2010, 3:34 AM EDT
Hi Shaul Thabz Here, I am a third year software development student , and i am doing a project and i would like to/already used your speech test sample as a guidence to my project but there is a platform problem because using Vista or Windows seven your sample code works well but on your normal windows xp i encountered problems and my guess is that there is something i did not include or insatall thus it does as a result not recognize the speechlib import please give me some pointers I`ll reall appriciate it it
mohamed sayedPosted Jul 6, 2010, 12:44 AM EDT
very good
diya khanPosted Jul 5, 2010, 2:02 AM EDT
hi, i m a final year student..sir how can i recognize digits..i dont want too use speech SDK for that...I want to make my speech engine for that..plz sir help mee in this
njohn lackyPosted Jun 21, 2010, 3:38 AM EDT
hey sir good job!!!! i think this is amazing! can "speech recognition" works in other programming languages???
Finto VadakkanPosted Jun 17, 2010, 7:57 PM EDT
hi, I am a student and i need to prepare my 6th mca project i am intrested in your topic speech recognition so please mail me the details of the project
Charith LiyanagamagePosted May 31, 2010, 7:34 PM EDT
Hi, We know that, if we developed any speech recognition application, first we have to train the voice. Is there anyway to doing the speech training through the same application? Thnaks, Charith
Peng LiangPosted May 31, 2010, 10:24 AM EDT
thx for share
john doePosted May 29, 2010, 3:01 AM EDT
Hi Suhil, I am a student in my final year and I am doing a project with ASR written in C# using SAPI 5.4 on Windows 7. I need an example of a conversation between a virtual agent and a user (witout gui - only the sound) containing a saving of the first user sentence to an audio file and the next user sentence (date and time) will be transcribed to text and put in a table in the DB with a reference to the audio file. The Voice User Interface (VUI) should be managed by a State Machine. Can you help me with that? I will be very greatful... Thanks
noppakun sangkabkaewPosted May 21, 2010, 8:40 PM EDT
this code can't work in windows7 how to do? plz help me [email protected]
kk kkPosted Apr 24, 2010, 3:45 AM EDT
thanks for u r code help full and i want to web based voice recognition sample code and methods.
azizul ismailPosted Apr 18, 2010, 8:01 AM EDT
Hello there, my name Azizul and I'm from Malaysia. I'm study at Local University and right now I have a project that convert speech to text. I use HM2007-speech recognition IC in this project. I used C language in PIC16F877A to convert the output from the IC to text and display the text at LCD 2x16 lines. I you don't mind, can you send me examples of the programming.
Giancarlo ColmenaresPosted Jan 30, 2010, 10:34 AM EST
Hi, great article. My question here is: What's neccesary to implement this on a web page?. I completely implemented this in a form-based application and it worked, but when I try to do it on web it doesn't work. Thanks
Charith LiyanagamagePosted Jan 1, 2010, 7:35 PM EST
in order to run this app is it must to have SDK 5.1...??? i have installed VS2008 in my pc. is it enough...??? if you could please submit the same source code for .net 3.5 (vs 2008). I'm using Win XP sp2
adam alaydrusPosted Dec 24, 2009, 1:43 AM EST
im student diploma in eepis indonesia can you help me for my final project?how to or where i can get source code for command button using speech in visual c++...im sorry this forum for c# but i dont know with visual c++ and im sorry with with my english.thanks regard....
mahesh kumarPosted Sep 18, 2009, 6:06 AM EDT
great job........i was looking for such tutorials...thanks Mahesh Kumar http://mdhiman.co.cc
soliman saidPosted Aug 13, 2009, 4:26 PM EDT
thanks
usman akbarPosted Jul 26, 2009, 5:27 AM EDT
sir i need this complet code on C# plz...
mahmoud almojahedPosted Apr 20, 2009, 11:01 AM EDT
how can i download this product?
Kalpesh JainPosted Mar 13, 2009, 7:47 PM EDT
I just want to open a form using voice command..............plz do help me with an appropriate code................ what all steps r needed
Kalpesh JainPosted Mar 13, 2009, 7:45 PM EDT
xcvxv
mike tanPosted Jan 21, 2009, 6:22 PM EST
hello, can you please help me with my project? It is about speech recognition that is to be embedded on a device that the device can be of use by using the speech recognition please do help me,thank you Godbless ^^,
devvvyPosted Jan 16, 2009, 10:29 PM EST
Where to download SpeechLib?
Tshiamo SigwelePosted Dec 17, 2008, 11:36 AM EST
Hi there,i am making a windows forms text to speech project using c# ,all i need is read text on a texbox when pressing a button.I have installed SDK 5.1 and i dont know where to start.Am using Visual studio 2005
wael batPosted Dec 5, 2008, 12:55 PM EST
give me the steps how work this prog to understand it i will used it in my project
EdoPosted Nov 23, 2008, 11:25 PM EST
hi, i just wondering, can u give me the source code, cause,really, i got stuck around with this subject, and anyway, what kind of method u using ???? thank u...
noha ahmedPosted Oct 20, 2008, 11:27 AM EDT
can u send me please the source code i need it so much
Kah Yung SiawPosted Oct 19, 2008, 6:59 AM EDT
Hello, I am a final year student doing a final year project. I am thinking doing control of home security devices through speech recognition send by mobile phone. I will be grateful if you advice me on whether it would work and teach me the best way to achieve it. Thank you. Regards, skyung
Vikasitha AnishiyasPosted Feb 29, 2008, 5:36 PM EST
hi... Im Vikasitha final year student... My project is speech to text sms... I need some guidance to speech recognition using .net compact framework.. that'll be very helpful.. pls rply.. thanks in advance...
SherwineditedPosted Feb 10, 2008, 5:58 PM ESTEdited Feb 10, 2008, 6:45 PM EST
what should i do be able to implement using SpeechLib; ?
sanjay kumarPosted Jan 7, 2008, 7:55 AM EST
hi..we r doing a project on speech recognition ..we want code in java ...can u help us ?we r in trouble......please reply..
kannan c seditedPosted Nov 5, 2007, 12:24 AM ESTEdited Nov 5, 2007, 12:43 AM EST
I am kannan,student. I wish to do "speech detection" for my academic project. please send me the source code for this project.
Asad aliPosted Aug 12, 2007, 11:21 AM EDT
My problem is that i am working on Microsoft SDK Speech in Asp.net. i have declare two events by using the object objRecocontext of SpeechLib.SpSharedRecoContext and do that to make two event handler objRecoContext.Hypothesis += new _ISpeechRecoContextEvents_HypothesisEventHandle(Hypo_event); // Assign a eventhandler for the Recognition Event. objRecoContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(Reco_event); My problem is that in asp these events not activated when i Speak after loading the grammer however these events work in Window forms properly. Somebody can tell about that problem plzzzz. it is urgent... Thanks
Robert LokePosted Jul 17, 2007, 12:09 AM EDT
Hi all! trying to adapt this example to german, I didn't find any hint on how to select the language to be recognized. Can somebody help me and give a hint? Thanks
Madhusudan ReddyPosted Jul 5, 2007, 4:40 AM EDT
HI, Im getting following exception when instantiating an object of spSharedrecocontext class objRecoContext = new SpeechLib.SpSharedRecoContext(); Exception Details: Creating an instance of the COM component with CLSID {47206204-5ECA-11D2-960F-00C04F8EE628} from the IClassFactory failed due to the following error: 8004503a.
np shPosted Mar 21, 2007, 8:18 AM EDT
could not download speechtest.zip i anybody have this zip file please send it to [email protected]
JimPosted Mar 3, 2007, 4:43 PM EST
hey whenever i try to run any code for speech recognition i get a runtime error with this code this particular part of the code is highlighted SpeechLib.SpSharedRecoContext() Is there anything I am missing that enables this not to run correctly?
mohamed almotawakileditedPosted Nov 29, 2006, 9:55 AM ESTEdited Nov 29, 2006, 10:01 AM EST
hi my dear brother thank you very much for your wonderful article about elementary knowledge of speech recognition , the best wishes for you . i have a problem that i can`t download the source file speech_test.zip which is attached to this article because my network interface does not support this type of interface can you send it to my e_mail: ([email protected]) if you have enough time . i hope that i will not bother you . your sincerly mohamed almotawakil
khanhPosted Mar 30, 2006, 12:31 AM EST
I want to use an InprocRecognizer but my program can not recognize when my application launches. Please tell me how can I create an application using InProcRecognizer. Thank you very much.
nickPosted Mar 11, 2006, 10:41 AM EST
Hi, I am a student and I need to prepare my 3rd year project. I have chosen speech recognition c# web interface and sql database. The last two I am actually studying and I saw your article about speech recognition. Is there a way you could help me with this part? Regards, Nick