Blue Theme Orange Theme Green Theme Red Theme
 
Discover the top 5 tips for understanding .NET Interop
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Discover the top 5 tips for understanding .NET Interop
Search :       Advanced Search »
Home » Speech in C# » Speech Recognition using C#

Speech Recognition using C#

This article provides some elementary information about how to implement Speech Recognition capabilities in to your applications using C# and Speech SDK 5.1.

Page Views : 218849
Downloads : 10927
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
SpeechTest.zip
 
 
Mindcracker MVP Summit 2012
Become a Sponsor
Nevron Chart
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Description

This article provides some elementary information about how to implement Speech Recognition capabilities in to 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 an 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 in to a applications. 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 the 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 the 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 an 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 screen shot below shows the main form of the sample application.



Summary

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

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Suhil Srinivas
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.
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the top 5 tips for understanding .NET
Ricky Leeks presents the top 5 tips for understanding .NET Interoperability. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Discover the top 5 tips for understanding .NET Interop
Become a Sponsor
 Comments
speech by nick On March 11, 2006

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

Reply | Email | Modify 
How to Use an InprocRecognizer by khanh On March 30, 2006

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.

Reply | Email | Modify 
please help me by mohamed On November 29, 2006

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: (oldsanaa2000@yahoo.com)

if you have enough time .

i hope that i will not bother you .

your sincerly

mohamed almotawakil

Reply | Email | Modify 
problem by Jim On March 3, 2007
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?
Reply | Email | Modify 
could not download speechtest.zip file by np On March 21, 2007
could not download speechtest.zip i anybody have this zip file please send it to narayansahu@yahoo.com
Reply | Email | Modify 
getting error when instantiating spsharedrecocontext object by Madhusudan On July 5, 2007
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.
Reply | Email | Modify 
Re: getting error when instantiating spsharedrecocontext object by Martin On February 17, 2009
I had the same error I believe but all I got to do was to download and install the newest version, Speech SDK 5.1. Which can be found eg. here. I take it that you allready have solved it but other might wonder...
Reply | Email | Modify 
language selection by Robert On July 17, 2007
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
Reply | Email | Modify 
SpeechLib in Asp.net by Asad On August 12, 2007
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
Reply | Email | Modify 
source code by kannan On November 5, 2007
I am kannan,student. I wish to do "speech detection" for my academic project. please send me the source code for this project.
Reply | Email | Modify 
speech recognition in mobile system by sanjay On January 7, 2008
hi..we r doing a project on speech recognition ..we want code in java ...can u help us ?we r in trouble......please reply..
Reply | Email | Modify 
HI I'm Implenting a Voice Recogntion in my Thesis by Sherwin On February 10, 2008
what should i do be able to implement using SpeechLib; ?
Reply | Email | Modify 
Speech to Text SMS by Vikasitha On February 29, 2008
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...
Reply | Email | Modify 
Seeking For Advice by Kah Yung On October 19, 2008
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
Reply | Email | Modify 
need help by noha On October 20, 2008
can u send me please the source code i need it so much
Reply | Email | Modify 
little help for the source code by Edo On November 24, 2008
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...
Reply | Email | Modify 
how work this program by wael On December 5, 2008
give me the steps how work this prog to understand it i will used it in my project
Reply | Email | Modify 
text to speech by Tshiamo On December 17, 2008
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
Reply | Email | Modify 
Re: text to speech by Avinash On January 5, 2009
http://www.c-sharpcorner.com/UploadFile/ggaganesh/BuildingTextSpeechApplicationsusingSAPI5.1andCSharp11222005235840PM/BuildingTextSpeechApplicationsusingSAPI5.1andCSharp.aspx

Above mention link is better Article For text to speech...
Reply | Email | Modify 
Where to download SpeechLib? by devvvy On January 17, 2009
Where to download SpeechLib?
Reply | Email | Modify 
gud day by mike On January 21, 2009
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 ^^,
Reply | Email | Modify 
xcvx by Kalpesh On March 13, 2009
xcvxv
Reply | Email | Modify 
Form opening using Speech Recognition by Kalpesh On March 13, 2009
I just want to open a form using voice command..............plz do help me with an appropriate code................ what all steps r needed
Reply | Email | Modify 
how can i by mahmoud On April 20, 2009
how can i download this product?
Reply | Email | Modify 
Request by usman On July 26, 2009

sir i need this complet code on C# plz...

Reply | Email | Modify 
thanks by soliman On August 13, 2009
thanks
Reply | Email | Modify 
Very nice Speech Controlled application by mahesh On September 18, 2009
great job........i was looking for such tutorials...thanks

Mahesh Kumar

http://mdhiman.co.cc
Reply | Email | Modify 
nice progrraming by adam On December 24, 2009
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....
Reply | Email | Modify 
Speech Recognition using C# by Charith On January 2, 2010
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
Reply | Email | Modify 
This on asp by Giancarlo On January 30, 2010
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
Reply | Email | Modify 
HELP PLEASE!! by azizul On April 18, 2010
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.
Reply | Email | Modify 
Thanks for ur help and i want web based voice recognition by kk On April 24, 2010
thanks for u r code help full and i want to web based voice recognition sample code and methods.
Reply | Email | Modify 
help me plz by noppakun On May 22, 2010
this code can't work in windows7
how to do?

plz help me

game_it@hotmail.com
Reply | Email | Modify 
HELP in a project! by john On May 29, 2010
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
Reply | Email | Modify 
thx by Peng On May 31, 2010
thx for share
Reply | Email | Modify 
Speech Training by Charith On May 31, 2010
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
Reply | Email | Modify 
hai by Finto On June 17, 2010
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

Reply | Email | Modify 
-_- by njohn On June 21, 2010
hey sir good job!!!! i think this is amazing! can "speech recognition" works in other programming languages???
Reply | Email | Modify 
wants help by diya On July 5, 2010
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
Reply | Email | Modify 
good by mohamed On July 6, 2010
very good
Reply | Email | Modify 
encountered Problems when changing the platform by Thabiso On August 11, 2010

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 

Reply | Email | Modify 
EKS by Rakesh On September 20, 2010
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.
Reply | Email | Modify 
need help.. by CHRISTEENA On January 4, 2011
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
Reply | Email | Modify 
For all dictionary words by aman On May 24, 2011
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
Reply | Email | Modify 
Words Recognition From wav file by Ponvel On June 20, 2011
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
Reply | Email | Modify 
hi plz help me by chethan On July 26, 2011
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
Reply | Email | Modify 
arabic speech recognition by samar On August 4, 2011
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
Reply | Email | Modify 
can u tell me how to make a voice enable browser by aneel On August 9, 2011
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..
Reply | Email | Modify 
Good Job by Anfil On September 21, 2011
Good Job
Reply | Email | Modify 
not working by vinod On October 20, 2011
when i enable speech button and say new its not working ?
Reply | Email | Modify 
thanks.................. :) by jd On January 10, 2012
Workin Great...........
Reply | Email | Modify 
hi by amarjith On January 28, 2012
Could you tell me this SpeechLib works on web application, I want display user speech in textbox. please help me thanking you.
Reply | Email | Modify 
Nevron Chart
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.