Blue Theme Orange Theme Green Theme Red Theme
 
Home | Forums | Videos | Photos | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
Search :       Advanced Search »
Home » Speech Programming » 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.

Total page views :  117397
Total downloads :  5988
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
SpeechTest.zip
 
Become a Sponsor

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.


Login to add your contents and source code to 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.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010 Professional
Microsoft Visual Studio 2010 Professional will launch on April 12, but you can beat the rush and secure your copy today by pre-ordering at the affordable estimated retail price of $549 (US). Pre-order now.
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.
Developer-Ready ASP.NET 2.0 Web Hosting with 3 MONTHS FREE
Now supporting .NET 3.0 Framework with Windows Workflow Foundation, Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF), windows CardSpace (WCS)! Providing more flexibility for Developers with Web Services Support and a User/Permission Manger. Also supporting MS SQL 2005/2000 with Real-Time Backups, FREE Automated Attach .MDF Tool, FREE SQL Restore and Shrink SQL DB Tools, and SQL
 
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
SpeechTest.zip
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | Modify | 
HI I'm Implenting a Voice Recogntion in my Thesis by Sherwin William On February 10, 2008
what should i do be able to implement using SpeechLib; ?
Reply | Email | Delete | 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 | Delete | 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 | Delete | Modify | 
need help by noha On October 20, 2008
can u send me please the source code i need it so much
Reply | Email | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | Modify | 
Where to download SpeechLib? by devvvy On January 17, 2009
Where to download SpeechLib?
Reply | Email | Delete | 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 | Delete | Modify | 
xcvx by Kalpesh On March 13, 2009
xcvxv
Reply | Email | Delete | 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 | Delete | Modify | 
how can i by mahmoud On April 20, 2009
how can i download this product?
Reply | Email | Delete | Modify | 
Request by usman On July 26, 2009

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

Reply | Email | Delete | Modify | 
thanks by soliman On August 13, 2009
thanks
Reply | Email | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 2010  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.