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, 1:02 PM
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, 5:18 AM
i Want To Create Some Speech To Text Application and this not working for me pls Help
ANkur bhargavPosted Jun 6, 2015, 5:16 AM
Can Some One Help
ANkur bhargavPosted Jun 6, 2015, 5:16 AM
its not working what i say
Pierre FournierPosted May 30, 2013, 10:42 AM
How you set the input for microphone ?
tofaaPosted Nov 16, 2012, 3:39 AM
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, 4:37 AM
For non-native english speakers this is absolutely useless.
laxmi lodhPosted Apr 17, 2012, 6:13 AM
plz upload correct code
sathish kumarPosted Mar 8, 2012, 6:16 AM
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, 5:34 PM
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, 9:10 AM
Workin Great...........
vinod sengarPosted Oct 20, 2011, 12:55 AM
when i enable speech button and say new its not working ?
AnfilPosted Sep 21, 2011, 2:03 AM
Good Job
aneel kumarPosted Aug 9, 2011, 4:44 AM
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, 5:47 PM
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, 10:15 AM
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, 11:47 AM
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 24, 2011, 3:44 AM
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 4, 2011, 2:31 AM
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 20, 2010, 2:02 AM
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, 7:34 AM
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, 4:44 AM
very good
diya khanPosted Jul 5, 2010, 6:02 AM
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, 7:38 AM
hey sir good job!!!! i think this is amazing! can "speech recognition" works in other programming languages???
Finto VadakkanPosted Jun 17, 2010, 11:57 PM
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, 11:34 PM
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, 2:24 PM
thx for share
john doePosted May 29, 2010, 7:01 AM
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 22, 2010, 12:40 AM
this code can't work in windows7 how to do? plz help me [email protected]
kk kkPosted Apr 24, 2010, 7:45 AM
thanks for u r code help full and i want to web based voice recognition sample code and methods.
azizul ismailPosted Apr 18, 2010, 12:01 PM
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, 3:34 PM
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 2, 2010, 12:35 AM
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, 6:43 AM
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, 10:06 AM
great job........i was looking for such tutorials...thanks Mahesh Kumar http://mdhiman.co.cc
soliman saidPosted Aug 13, 2009, 8:26 PM
thanks
usman akbarPosted Jul 26, 2009, 9:27 AM
sir i need this complet code on C# plz...
mahmoud almojahedPosted Apr 20, 2009, 3:01 PM
how can i download this product?
Kalpesh JainPosted Mar 13, 2009, 11:47 PM
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, 11:45 PM
xcvxv
mike tanPosted Jan 21, 2009, 11:22 PM
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 17, 2009, 3:29 AM
Where to download SpeechLib?
Tshiamo SigwelePosted Dec 17, 2008, 4:36 PM
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, 5:55 PM
give me the steps how work this prog to understand it i will used it in my project
EdoPosted Nov 24, 2008, 4:25 AM
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, 3:27 PM
can u send me please the source code i need it so much
Kah Yung SiawPosted Oct 19, 2008, 10:59 AM
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, 10:36 PM
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, 10:58 PMEdited Feb 10, 2008, 11:45 PM
what should i do be able to implement using SpeechLib; ?
sanjay kumarPosted Jan 7, 2008, 12:55 PM
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, 5:24 AMEdited Nov 5, 2007, 5:43 AM
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, 3:21 PM
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, 4:09 AM
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, 8:40 AM
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, 12:18 PM
could not download speechtest.zip i anybody have this zip file please send it to [email protected]
JimPosted Mar 3, 2007, 9:43 PM
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, 2:55 PMEdited Nov 29, 2006, 3:01 PM
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, 5:31 AM
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, 3:41 PM
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