HeadsetOk. I confess! I am a .NET junkie. It’s true. I have a real fetish for the framework. But, before you judge me, let me show you why. Better yet, let me show you an example of why I’m so fond of the Microsoft .NET Framework.

If any of you have ever done any kind of speech recognition or speech-to-text applications without using .NET, then you should already know how difficult it is to do. Even using libraries like Microsoft’s Speech API can be a real hassle. However, the .NET framework provides us with everything we need for creating speech-capable applications. The framework does all of the heavy lifting, leaving you with very minimum code to write. To prove it, I want to take a minute to show you a very simple C# application that can type out anything you say. So, let’s begin.

To begin this example, you will need to fire up Visual Studio and create a new Windows Application. Before writing any code, you will need to first add a reference to the System.Speech component. You can do this by right-clicking on “References” in your Solution Explorer and selecting “Add Reference…”. When the “Add Reference” dialog appears, scroll down and select “System.Speech” and click the “OK” button.

Now that you have added a reference to the Speech component, you should go ahead and setup your form by double-clicking “Form1.cs” in the Solution Explorer. For this example, you will need to add a Rich TextBox control and 2 buttons, one for starting the speech recognition and the other for stopping it. You can combine these 2 buttons into 1 if you want. But for demo purposes, we will keep them separate. Here is what my form looks like if you need something to reference.

Speech Recognition Example Form

Once you have your form ready, it’s time to add some code. So, once again, click once on “Form1.cs” in your Solution Explorer and click the “View Code” button at the top. Visual Studio Solution Explorer - View Code The first thing you will need to add to your code is a reference to the System.Speech namespace we added earlier. You can do that by adding the following line to the top of your source code along with the other using statements.

using System.Speech.Recognition;

Next, you will need to setup a new SpeechRecognitionEngine object and since you’ll be reusing this object, you’ll need to add it as a global variable.

private SpeechRecognitionEngine recognitionEngine;

Now that you have your speech engine ready, you’ll need to instantiate and initialize it inside the form constructor.

recognitionEngine = new SpeechRecognitionEngine();

To keep things simple, you’ll also want to go ahead and set the input to use your computer’s default audio device. Lucky for us, .NET makes this step easy as well by calling the SetInputToDefaultAudioDevice method like so:

recognitionEngine.SetInputToDefaultAudioDevice();

While you’re at it, you’ll also want to add a new handler for whenever speech has been captured by adding the “SpeechRecognized” event. In that handler, you can do all kinds of things like checking the level of confidence that the engine has determined that each word actually is. You can change the minimum confidence level if you feel that the engine isn’t accurately recognizing your words. Also in that handler, you will want to go ahead and add any recognized words to the rich text box control you added to your form. As you’ll see in the code below, I named my rich text box “txtOutput”. But you can leave yours as the default or change it to whatever you want.

recognitionEngine.SpeechRecognized += (s, args) =>
{
foreach (RecognizedWordUnit word in args.Result.Words)
{
if (word.Confidence > 0.8f)
txtOutput.Text += word.Text + ” “;
}
txtOutput.Text += Environment.NewLine;
};

After you’ve added a new event handler for printing detected text, you will need to load at least one grammar object by calling the LoadGrammar method and passing it a new DictationGrammar like this:

recognitionEngine.LoadGrammar(new DictationGrammar());

Not bad so far, huh? Well, the next 2 parts are extremely easy. All we have left to do now is to add the code needed to make tell our speech engine to begin listening and to stop listening. To do that, go to your form and double click the Start button to add a click event handler to the button. Inside your click event handler, the only thing you need to do is call the RecognizeAsync method. You will also need to tell it which RecognizeMode to use: either Single or Multiple. I use multiple so that the engine will listen for entire sentences before processing the input.

recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);

The only thing you have left to do now is tell the engine to stop listening by calling RecognizeAsyncStop from your Stop button click event handler.

recognitionEngine.RecognizeAsyncStop();

That’s it! You now have everything need for capturing speech and displaying it in a Rich TextBox by using the .NET Speech component and C#. Go ahead and test it by running the application and clicking the Start button. That will tell the engine to start listening for speech. At this point, go ahead and do some talking. If everything went as described, you should see your words typed out in the text box. If you do not see your words being typed out, make sure that your microphone is not muted and that the volume of it is turned up loud enough. If the engine isn’t doing a good enough job of recognizing your words, try changing the confidence level as mentioned above.

Below you will find the complete source code for this project. Tomorrow, I will expand on this tutorial by showing you how to listen for specific commands and performing different tasks based on those commands. For example, I will show you how to listen for names of applications and how to open the applications that correspond to those names.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Recognition;

namespace SpeechRecognitionExample
{
    public partial class Form1 : Form
    {
        private SpeechRecognitionEngine recognitionEngine;

        public Form1()
        {
            InitializeComponent();

            recognitionEngine = new SpeechRecognitionEngine();
            recognitionEngine.SetInputToDefaultAudioDevice();
            recognitionEngine.SpeechRecognized += (s, args) =>
            {
                foreach (RecognizedWordUnit word in args.Result.Words)
                {
                    if (word.Confidence > 0.8f)
                        txtOutput.Text += word.Text + " ";
                }
                txtOutput.Text += Environment.NewLine;
            };
            recognitionEngine.LoadGrammar(new DictationGrammar());
        }

        private void btnStart_Click(object sender, EventArgs e)
        {
            recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            recognitionEngine.RecognizeAsyncStop();
        }
    }
}

Related Posts

Tagged with:  

56 Responses to Simple Speech Recognition Using C#

    • yogesh says:

      Hello LuCuS,
      I referred your sample code and creating vb.net application. This is data entry application which have 20+ fields on vb.net form.
      - I got it working where voice recognition happening and results being dumped in single text field

      I want to get following functionality in this application
      - I shall be able to navigate between fields using voice command e.g. First Name, Last Name, DOB, etc and enter its values
      - I shall able to add record and get fields setup for next new records
      - This need to be done so there is limited voice interaction for navigation and control

      May I request your help with suggestions / approach for above solution.

      Thanks –
      Yogesh

      • LuCuS says:

        I haven’t done much VB.net programming in a while, but I’ll try to throw out a few pointers anyways. To get the behavior you’re looking for, you can approach it 2 different ways. You can either hardcode the name of each of your fields and associate those with words / phrases using a “Grammar Builder” object as shown in this comment: http://www.prodigyproductionsllc.com/articles/programming/simple-speech-recognition-using-c/#comment-682. The other approach you could use is to listen for a word or phrase such as “next” or “next field” and issue a “tab” command. Since each field on your form has a “tab index”, you could also issue a “previous” or “previous field” command to navigate backwards and forward thru your form fields based on this property.

    • shuvro says:

      LuCuS,how can i interact mouse pointer and speech recognition in C#?Suppose i will tell “Left” and then mouse will move towards left.Similarly,moves right when i tell “Right”.If it is possible then can u give a tutorial over this topic or can you suggest any link of this topic?Thanks for any advance..

      • LuCuS says:

        Sorry. I’ve been going hard and heavy on my new startup lately. We’re shooting for a June release and I’m devoting everything I have to make sure we hit that deadline. However, I did find a few minutes to throw together an example app for you. Basically, it listens for the commands “up”, “down”, “left”, and “right”. Whenever it hears those commands, it moves the mouse pointer in increments of 50 in the direction you speak. Right now, the mouse jumps in increments of 50. But, it can be easily modified to make smooth transitions by taking the current mouse position and moving to the new position by using a timer object or thread with a sleep of a few milliseconds and subtracting the difference between your current mouse position and your new position upon every iteration. As soon as I get time, I’ll write up a full explanation of what’s going on in the app and how to improve it. Until then, you can download the app from http://www.prodigyproductionsllc.com/downloads/MouseController.zip Let me know if that helps.

  1. Stiger says:

    Thank u for this great article,
    but i have 1 problem when i debug this it shows me near :

    recognitionEngine.SetInputToDefaultAudioDevice();

    ((Value does not fall within the expected range.))

    what should i do.

    i have windows XP and .NET 4.0 and visual studio 2011 ultimate
    and this is my coding :

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Speech.Recognition;

    namespace Voice_recognition
    {
    public partial class Form1 : Form
    {
    private System.Speech.Recognition.SpeechRecognitionEngine recognitionEngine;
    public Form1()
    {
    InitializeComponent();

    recognitionEngine = new SpeechRecognitionEngine();
    recognitionEngine.SetInputToDefaultAudioDevice(); // here it gives me that error
    recognitionEngine.SpeechRecognized += (s, args) =>
    {
    foreach (RecognizedWordUnit word in args.Result.Words)
    {
    if (word.Confidence > 0.8f)
    txtOutput.Text += word.Text + ” “;
    }
    txtOutput.Text += Environment.NewLine;
    };
    recognitionEngine.LoadGrammar(new DictationGrammar());
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {
    recognitionEngine.RecognizeAsync(RecognizeMode.Multiple);
    }

    private void button2_Click(object sender, EventArgs e)
    {
    recognitionEngine.RecognizeAsyncStop();
    }
    }
    }

    • LuCuS says:

      Do you have a default input device? I created this using my laptop which has a built-in microphone. I’m not sure how to check for the default input device in XP, but I’m sure it’s similar to the way it’s done in Vista. To check that you have a default input device installed on Vista, click on Start > Control Panel and open “Sound”. Swap over to the “Recording” tab and you’ll see a list of all of your input devices (microphone, line in, bluetooth, etc…). Make sure that you have the device you want to work with set as default by clicking that device and clicking the “Set Default” button. If that doesn’t help, let me know and I’ll dig up one of my older XP laptops and will see if I can replicate your error.

  2. shuvro says:

    I am doing such a programme which writes words when i speak something.But how can i use Space,Backspace and Enter command for removing a word or start it from a newline.Can you give suggestions?

    • LuCuS says:

      One way you could do it is to check the words as they come in and act accordingly. For instance, at line 28 in the example above, you could check for words such as “space”, “backspace” (or probably “back space”), and “enter”. When it sees those words, print an actual space or line return instead of printing the word. Here’s the code:

      foreach (RecognizedWordUnit word in args.Result.Words)
      {
      if (word.Confidence > 0.8f)
      {
      if(word.Text.Equals("space"))
      txtOutput.Text += " ";
      else if(word.Text.Equals("enter"))
      txtOutput.Text += "\n";
      else if(word.Text.Equals("backspace"))
      txtOutput.Text = txtOutput.Text.Substring(0, txtOutput.Text.Length - 1);
      else
      txtOutput.Text += word.Text + " ";
      }
      }

      There are also ways of adding specific keywords to your GrammarBuilder to watch for. Here’s a function I wrote for another speech recognition article that listens for specific keywords. In this case, it’s listening for names of applications and will execute the application that is called. So, if you say “start notepad”, Windows will run Notepad.exe.

      private Grammar CreateGrammarObject()
      {
      Choices commandChoices = new Choices("Calculator", "Notepad", "Internet Explorer", "Paint");
      GrammarBuilder grammarBuilder = new GrammarBuilder("Start");
      grammarBuilder.Append(commandChoices);
      Grammar g = new Grammar(grammarBuilder);
      //g.Name = "Available programs";
      return g;
      }

      To use this function, you will need to replace line 32 with this:

      recognitionEngine.LoadGrammar(CreateGrammarObject());

      I know a lot of people like to replace “new GrammarBuilder(“Start”)” with “new GrammarBuilder(“Computer”)”. That way, any time you say something that begins with the word “computer”, the computer will accept anything after that as a command. Kinda gives it the whole Star Trek feel. :-)

      Here is the link to the other article where I talk about creating custom Grammar Builders: http://www.prodigyproductionsllc.com/articles/programming/simple-speech-recognition-using-c-part-2/

      • shuvro says:

        Thanks for your suggestion.But it is not working.When i spell words it writes as well i said,but when i say “enter” or ”backspace” it not works.Your idea is logically correct,it seems to me but why it not works i also can’t understand.Again thanks for your reply.

        • LuCuS says:

          One thing you’ll need to do is to remove the line that says “txtOutput.Text += Environment.NewLine;”. Then everything should begin working for you. Also, in the code snippet I sent you yesterday, the “else” part adds an extra space after each word. Once you remove the “txtOutput.Text += Environment.NewLine;” line, you should be good to go. Keep in mind though, that since an extra space is always added after every word, the first time you say “backspace”, you’ll be deleting that space. So, say “backspace” again and you’ll back over the last letter of your text. For example. I tested with:

          “this is a test”

          Then, I said “backspace” twice and ended up with:

          “this is a tes”

          You can remove the extra space if you want, but you’ll have to say the word “space” between every word”. For example:

          “this space is space a space test enter”

  3. shuvro says:

    Thanks one more time for this great article and your suggestion of my problem.This works now as well as i want.Your article is very helpful for those who want to develop speech based application.I wish you will keep on it..

    • LuCuS says:

      Thank you! I appreciate your kind words. I’m also glad you found this article helpful. Good luck with your project and feel free to message me any time if there is anything else I can help with.

  4. shuvro says:

    How can i differentiate between capital A and small a(same to other alphabets..) if i want to print them individually throw speech?

    • LuCuS says:

      If you’re only planning on upper casing 1 character at a time (ex: A B C and not Apple Banana Car), you could add a GrammarBuilder object that includes the phrase “upper case”. Then, whenever your app recognizes that phrase, it will automatically uppercase the following character or word. That would allow you to say something like:
      I was visiting the ‘upper case‘ u ‘upper case‘ s ‘upper case‘ a

      The output would then be:
      I was visiting the U S A

      If you’re wanting to do something like capitalizing names, you’ll need to look into using something like wordnet that is built with a list of people and places that would be automatically capitalized when detected.

  5. shuvro says:

    Well,your application shows how the computer listens my speech and print them in word by word basis,that means i have to speak word by word and the computer will print it.Then if i want to speak an entire sentence fluently,will it print correctly?If not then what will be the process for that?

    • LuCuS says:

      The example above actually does listen for entire sentences. The SpeechRecognitionEngine at line 21 takes in everything that it “hears” and doesn’t stop listening until it finds a pause, indicating a sentence break. Once the engine has detected a pause, the code runs thru all of the words that the engine knows of at that point at prints them along with a space after each word. Once it has printed all of the recognized words, it prints a line return and goes back to listening for more input. The SpeechRecognized call at line 23 is an event handler just like any other event handler. Even though the app is currently in the process of printing words / sentences, the engine is still running asynchronously awaiting more input. When it detects input, it falls into this handler where it gets spit out to the screen.

      I just did a test using the code above to verify that the app does do what I think you are intending for it to do. For my test, I spoke an entire sentence in a normal tone. I spoke:
      “This is a test of the emergency broadcast system.”
      (paused briefly and continued)
      “Had this been an actual emergency, I probably would not be here.”

      The app took in everything I said and printed the following output:
      “this is a test of the emergency broadcast system” (line return)
      “had this been an actual emergency i probably would not be here”

      At this point, all I would have left to do is add punctuation and capitalize the first letter of each sentence. So, to answer your question, the app is capable of listening for an entire sentence to be spoken fluently and will print correctly. It’s just a matter of what else you add to it to make it more complex than the simple example above.

  6. shuvro says:

    In a Text to Speech application i use following codes:

    SpeechSynthesizer synthesis = new SpeechSynthesizer();

    synthesis.SpeakProgress += new EventHandler(synthesis_SpeakProgress);

    void synthesis_SpeakProgress(object sender, SpeakProgressEventArgs e)
    {
    //show the synthesizer’s current progress
    labelProgress.Text = e.Text;
    }

    Where labelProgress shows the words being spoken when i press Speak button.But if i want to highlight those words in corresponding richtextbox,how can i do that? Do you have any suggestions?

    • LuCuS says:

      I would add a RichTextBox that displays the text that is being spoken. You can set this control to be readonly if you don’t want anyone typing into it or messing with the text that’s being spoken. I’m assuming you have a button that the user clicks to tell your app to begin speaking the text. If so, at the beginning of that function, I would set focus on the RichTextBox you added earlier. If you leave out this step, the text will never be highlighted because the control doesn’t have the cursor in it. So, if I named my RichTextBox control “txtOutputText”, I would add the following to the beginning of my button handler.

      txtOutputText.focus();

      Next, inside the synthesis_SpeakProgress event handler, I would tell that RichTextBox to select the text by character position like so:

      txtOutputText.Select(0, e.CharacterPosition);

      As the speaker speaks the text, you should see the text being highlighted in the RichTextBox. That’s it. Let me know if this helps.

  7. shuvro says:

    Thanks for this great suggestion.Yes,it works well..as i wish to do.But i wish to select only that word which is being spoken..instead your idea selects the past spoken words along with the new spoken word.I am not sure am i able to understand you..but once again thank you for your suggestion.

    • LuCuS says:

      For highlighting each word only, you could do something like check the character at e.CharacterPosition and if it is a space, highlight everything after that until you’ve reached either the next space or the end of the text. When the next space is reached in the synthesizer, the process will repeat.

  8. shuvro says:

    I can solve it by placing a small change only..

    richTextBox1.Select(e.CharacterPosition,e.Text.Length);

    which hignlights only the spoken word.Once again thanks for your suggestion.

  9. shuvro says:

    I have made a text to speech application which converts text to speech by clicking speak button.I put options for voice selection in a combo box.I also put options for saving audio in Wav format which is spoken.My computer’s default voice is Microsoft Anna.The problem is,if i select another voice(suppose,NeoSpeech Paul) from combo box and press the SaveAudio button..it saves the spoken word in default voice(Microsoft Anna) which is not right at all.So,voice is not changing in Saving audio options.What can be preferable solution for it? Here is my saving audio codes:


    SpFileStream spFileStream = new SpFileStream(); //declaring and Initializing
    //fileStream obj
    SpeechStreamFileMode spFileMode = SpeechStreamFileMode.SSFMCreateForWrite;
    //declaring fileStreamMode as to create or write

    SpVoice my_Voice = new SpVoice(); //declaring and initializing SpVoice Class

    SpeechVoiceSpeakFlags my_Spflag = SpeechVoiceSpeakFlags.SVSFDefault;
    //declaring and initializing speech voice flags

    private void saveButton_Click(object sender, EventArgs e)
    {
    SaveFileDialog sfd = new SaveFileDialog();
    sfd.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav";
    sfd.Title = "Save to a wav file.";
    sfd.FilterIndex = 2;
    sfd.RestoreDirectory = true;
    if (sfd.ShowDialog() == DialogResult.OK)
    {
    spFileStream.Open(sfd.FileName,spFileMode,false);
    my_Voice.AudioOutputStream = spFileStream;
    my_Voice.Speak(richTextBox1.Text,my_Spflag);
    my_Voice.WaitUntilDone(-1);
    spFileStream.Close();
    }
    }

    • LuCuS says:

      What does your code look like that changes the voice? Do you have your voices listed in a combo box? If so, you could always reset your voice to the selected combo box item at the start of your saveButton_Click handler. For example, right before the “SaveFileDialog sfd = ….” line, insert the following:

      my_Voice.Voice = my_Voice.GetVoices(“Name=” + cmbVoices.Text, “Language=409″).Item(0);

      That’s assuming you have your voices listed in a combo box called “cmbVoices”. I just threw together a quick app using this and it worked as expected. Here is my code for you to reference.


      using System;
      using System.Text;
      using System.Windows.Forms;

      using SpeechLib;

      namespace TextToSpeech
      {
      public partial class Form1 : Form
      {
      SpFileStream spFileStream = new SpFileStream();
      SpeechStreamFileMode spFileMode = SpeechStreamFileMode.SSFMCreateForWrite;
      SpeechVoiceSpeakFlags my_Spflag = SpeechVoiceSpeakFlags.SVSFDefault;

      SpVoice my_Voice = new SpVoice();

      public Form1()
      {
      InitializeComponent();
      }

      private void btnSave_Click(object sender, EventArgs e)
      {
      SaveFileDialog sfd = new SaveFileDialog();
      sfd.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav";
      sfd.Title = "Save to a wav file.";
      sfd.FilterIndex = 2;
      sfd.RestoreDirectory = true;
      if (sfd.ShowDialog() == DialogResult.OK)
      {
      spFileStream.Open(sfd.FileName, spFileMode, false);
      my_Voice.AudioOutputStream = spFileStream;
      my_Voice.Speak(txtInput.Text, my_Spflag);
      my_Voice.WaitUntilDone(-1);
      spFileStream.Close();
      }
      }

      private void Form1_Load(object sender, EventArgs e)
      {
      var voices = my_Voice.GetVoices();

      foreach (ISpeechObjectToken Token in my_Voice.GetVoices(string.Empty, string.Empty))
      {
      cmbVoices.Items.Add(Token.GetDescription(49));
      }

      cmbVoices.SelectedIndex = 0;
      my_Voice.Voice = my_Voice.GetVoices("Name=" + cmbVoices.Text, "Language=409").Item(0);
      }

      private void btnChangeVoice_Click(object sender, EventArgs e)
      {
      my_Voice.Voice = my_Voice.GetVoices("Name=" + cmbVoices.Text, "Language=409").Item(0);
      }

      private void btnSpeak_Click(object sender, EventArgs e)
      {
      my_Voice.Speak(txtInput.Text, SpeechVoiceSpeakFlags.SVSFDefault);
      }
      }
      }

      My form has a text box called “txtInput”, a combo box called “cmbVoices”, and 3 buttons called “btnChange” (for changing the voice to the selected voice in the combo box), “btnSpeak”, and “btnSave”.

  10. shuvro says:

    Ok,this is fine.But according to your code:

    private void btnSpeak_Click(object sender, EventArgs e)
    {
    my_Voice.Speak(txtInput.Text, SpeechVoiceSpeakFlags.SVSFDefault);
    }

    When it works,the system isn’t responding or stop working untill all the texts are read.More clearly,when i press btnSpeak,text to speech conversion begins.But at that time if i press btnSave it doesn’t works untill all the texts are read.Before your suggestion,for speak button i use,

    SpeechSynthesizer synthesis = new SpeechSynthesizer();
    synthesis.SpeakAsync(txtInput.Text);

    and for cmbVoices i use,

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
    if (comboBox1.SelectedItem != null)
    {
    synthesis.SelectVoice(comboBox1.SelectedItem.ToString());
    }
    }
    It solves that problem that i noticed you here but it cannot saves audio according to voice selection because synthesis() has no speak flag options.I don’t know whether i can understand you all my words.Thanks for your suggestion.

    • LuCuS says:

      The btnSpeak and btnSave buttons are completely separate of each other. The btnSpeak button is there only to have the app speak the text out loud and could’ve been left out entirely for my test example. The btnSave is pressed by itself to just take the text from the input box and save the audio version of the spoken text into a WAV file. In my example, the app appears to “freeze” until the speaking has finished. I could’ve gotten around this by having the speaking part take place in a thread of its’ own or by doing like you suggested and used SpeakAsync instead. But, all I was looking for was verification that the output WAV file was being spoken in the voice I selected in the combo box.

  11. shuvro says:

    How can i add an animated speaking character that can interact with user in my application?(Such as the character will say “Welcome”.Then the user will say “What is your name?”.The character will respond and say “I am Merlin”.Is it possible?) I use windows 7,Visual Studio 2010.I tried with msAgent from Microsoft AgentObjects,the problem is to load a character(such as Merlin) i need to add reference from AxAgentObjects.dll file.But in COM of .NET framework 4 i found AgentObjects which donot include AxAgentObjects.dll…..Are there any solution for it or how can i add such a character?Is it possible to create such a character without using AxAgentObjects.dll?

    • LuCuS says:

      AgentObjects is the only way I know of to do it using C#. I did this very thing a while back. I learned how to do it from the following tutorial: http://www.codeproject.com/KB/cs/announcer.aspx. It’s a bit outdated. So, I’m not sure if this same method works with VS 2010. I haven’t tried it in the new version. If it can work with 2010, you’ll probably have to download the AgentObjects.dll from the web.

  12. shuvro says:

    I am quite hopeless now after having a lot of task on Microsoft agent characters past 2 days.And finally i found..Windows 7 no longer directly support those characters.It only supports those by a software called Hotfix..but my computer don’t support that software….so building an application with those voice animated characters is now a dream to me which don’t come true in fact..thanks for your suggestion..it helps me a lot…and also ask to you,in Windows 7 platform are there any possible ways to add or make such a character in an application like your above Speech Recognition example..??

    • LuCuS says:

      I dug into this a little bit more and have got a working solution. You are correct that the Microsoft Agent was removed in Windows 7. However, you are also correct that Microsoft provides a soluton via it’s “Hotfix”. Hotfix is simply a Windows update. Every time your computer gets new Windows updates, it’s downloading these “hotfixes”. If you install the hotfix (which you can get from http://www.microsoft.com/products/msagent/main.aspx), you will be able to use the MSAgent in your apps. I’m using Windows 7 – 64bit and Visual C# 2010. Below you can see that it is working with no problems. I have put together a simple application for you showing how it works. You can get my example app from http://www.prodigyproductionsllc.com/downloads/MSAgent.zip. Let me know if this helps or if you need more details.

  13. shuvro says:

    Yes,there is a problem.Before your suggestion i tried hotfix,but i’m using windows 7 32 bit operating system…and during installation process of hotfix it shows that updates are not available for your computer and installation cancelled.So do i need to install 64bit windows 7 for this program?

  14. shuvro says:

    Yes it does…really thanks to you for this better suggestion..It works properly now and again you make me hopeful for making a better application with those animated characters.Thanks a lot..

  15. shuvro says:

    I have one more question.Is this animated character actually speaking? We see what he’s saying through a bubble but isn’t it possible to hear his voice by speaker or headphone? I don’t know actually for which i ask about that to you..(or may be a problem in my headphone for which i can’t hear!!)

    • LuCuS says:

      Yes. He actually does speak out loud. Make sure that your headphones are not muted and that the volume is turned up. When he speaks, you should see the word bubble as well as hear him thru your speakers / headphones.

  16. JimmyKomy says:

    Hey LuCuS, Will you make a new tutorial about voice recognition hope It will be very soon , I need it so much :D

  17. shuvro says:

    Actually there is a problem for hearing voices and now i can solve it.My computer lacks a text-to-speech engine and i install it.Now it works as sound.Well,i’m developing an advanced notepad application using speech recognition.It includes text to speech and speech to text conversion.I also looking for your next speech recognition article which includes XML grammer because i have some lack of accuracy in speech to text conversion…(now i am trying to develop it’s accuracy)..Hoping for a great article to you..Thanks once again….

  18. shuvro says:

    Hi LuCuS, I’m here again as i favour your tutorials.My previous project “Voice Notepad” is successfully over now.In different steps of this work when i face problems,i follow your instructions and that works great as i mentioned you earlier.So again thanks for your suggestions.Now my interest is on internet and building website.As I’m new in this field,i found you’re experienced one in this field.So i want to know from you, are there any tutorials written by you for building an efficient website? or can you suggest any link that can help me? I also don’t know what are the steps to build a website and what programming language should i follow(ASP/PHP,HTML,JAVASCRIPT,CSS).Can you suggest the right way?

    • LuCuS says:

      It really depends on what kind of website you’re wanting to build. Are you wanting to create a website that has some static pages? Are you wanting to create a blog type site (similar to mine)? Or are you wanting to create a web “application”. Keep in mind that web “sites” are different from web “apps”. Web “apps” are basically applications such as management tools that run within the browser. Web “sites” are simply pages that display standard stuff like my site. Do you have anything in particular you’re looking at doing? Will you be selling anything from your site? Will it require a database for storing user or other information?

    • LuCuS says:

      BTW, I do have several articles about web design. You can find those articles on the right side of this page by clicking “Web Design” under the “Categories” section. One article in particular you might want to checkout is http://www.prodigyproductionsllc.com/articles/web-design/building-a-website/.

  19. shuvro says:

    Thanks for your reply LuCuS.I wish to design a website just like yours…I’m not sure whether i can add so many functions like your website.But i will try to build a programming website as like yours where different users post comments,articles,share information etc.And i think it should be dynamic and it also require database as mentioned you.

    • LuCuS says:

      In that case, there are plenty of tools out there to choose from. The best part is that the “good” tools are all free, including the tool I use to run this site. Those tools are Joomla, Drupal, and WordPress. I use WordPress for this site. I have an article about installing WordPress at http://www.prodigyproductionsllc.com/articles/web-design/installing-wordpress/. I’m extremely happy with WordPress. It has everything you need right out of the box including an awesome admin panel (which is what you use to maintain users, articles, etc…). It also allows you to quickly and easily swap out your overall site design by picking from thousands of templates and clicking a single button to swap to the new design. It comes with an install script that when ran will connect to your database, create all of the required tables, and setup all your pre-configs. It supports all kinds of plugins to do pretty much anything you could ever need. I have a couple of articles on this site explaining some of the good plugins. Here is an older list of some of the plugins I use on this site: http://www.prodigyproductionsllc.com/articles/general/wordpress-plugins/. And, like I mentioned earlier, this is all free. However, I would recommend donating a few bucks back to anyone that provides a free template or plugin that you decide to use. Another cool thing about WordPress is that you, yourself can design new templates and plugins which you can sell for others to use. WordPress is written in PHP, Javascript, CSS, and HTML. So, if you decide to begin creating your own templates and plugins, those are the languages you need to learn.

  20. [...] right now because I’ve already explained the basics in my other speech recognition articles (1, 2, 3). Instead, I’m just going to post the code here for the rest of you to enjoy. The only [...]

  21. arun verma says:

    hello sir,
    thanks for posting this source code , but I found an error during debugging ” Value does not fall within the expected range.” while my microphone is detected by the system ,what should I do to correct this error . I am using windows xp operating system and visual studio 2008 .
    thank you.

Leave a Reply