.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to make a simple speech to text voice recognition example

Posted By:Evan Miller       Posted Date: July 07, 2011    Points: 200    Category: General    URL: http://www.dotnetspark.com  

This article is about the making of a voice recognition example in a SIP/VoIP phonecall.

Speech recognition is the process of converting spoken words to text. This technology has so many utilization possibilities, it made me wonder if I could build an application myself which is capable of such thing. I have done a lot of research until I have found a software development kit that has enabled me to finally start experimenting. This article is inspired to present my observations, and to give a technical review of making a softphone implementation uses voice recognition. My train of thought will be easier to follow, if you download the "Speech to Text" sample program from the site I've found. As I did.


Here's the source code for this sample program:

1.    private void buttonOpenFile_Click(object sender, System.EventArgs e)  

2.            {  

3.                using (OpenFileDialog openFileDialog = new OpenFileDialog())  

4.                {  

5.                    openFileDialog.Multiselect = false;  

6.                    openFileDialog.Filter = "Wav audio file|*.wav";  

7.                    openFileDialog.Title = "Open a Wav audio File";  

8.                    if (openFileDialog.ShowDialog() == DialogResult.OK)  

9.                    {  

10.                                           recognizer=new SpeechRecognitionEngine();  

11.                                           recognizer.SetInputToWaveFile(openFileDialog.FileName);  

12.                                           recognizer.LoadGrammar(new DictationGrammar());  


14.                                           RecognitionResult Result = recognizer.Recognize();  

15.                                   if (Result!=null)  

16.                                           {  

17.                                            foreach (RecognizedWordUnit Word in Result.Words)  

18.                                            {  

19.                                                listBoxResult.Items.Add(Word.Text);  

20.                                            }                  

21.                                   }  

22.                                       }  

23.                                   }              

24.                               }  

The file is loaded via the 'openfiledialog' object in a sample way. Then you need to create a new instance from the engine of voice recognition system. There is the opportunity to specify a predefined grammar or to create a new one by using the words you prefer.

In this case the built-in one is used but the other opportunity is better in the aspect of fastness. Because number recognition only requires a narrower cluster search than an extended recognition. Even in case you create your own grammar you do not need to do much just to build it up from the desired words and then to load it into the sound recognition engine.

Then set the sound source with which you would like to do the voice recognition. Since the speech.dll function directory supports the analysis directly from wav file, all you need to do is to set it 'recognizer.SetInputToWaveFile(openFileDialog.FileName);'.Then just invite the 'Recognize()' method that does the analyzation on the voice recognition engine. The result of recognition will be placed in a list and its content will be displayed on the screen via a listbox control.


On the site you will find another voice recognition example (a softphone) and the source code for it, too. I choose the one with the shorter code in order not to lose your attention. If you're interested you will look up the site anyway. Thanks for reading my article.

 Subscribe to Articles


Further Readings:

Author: Neetu         Company URL: http://www.dotnetspark.com
Posted Date: January 07, 2014

I was trying to convert speech to text file but did not get success. but this code helped me lot. Thank you very much, it is really very helpful.

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend