Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm trying to recognize what user is speaking using microphone and compare it with the predefined text and validate. I have used the System.Speech dll.
I have doubts regarding the same.

1.Currently I am using grammar builder with hard-coded values in it and matching it with what user is saying.My Code below.
Problem with below code is that sometimes it matches words which sound similar
for example "hear" and "year". Also if I have word say "developer" and if user says "development" then it will pick "developer" from grammar. So is there way to avoid it or increase the accuracy of it?

2. Is there a way where I can record everything what user has said and then compare it? If yes, then how?

What I have tried:

C#
static void Main(string[] args)
      {
          SpeechRecognizer recognizer = new SpeechRecognizer();

          Choices colors = new Choices();
          colors.Add(new string[] { "red", "green", "blue" });

          GrammarBuilder gb = new GrammarBuilder();
          gb.Append(colors);

          Grammar g = new Grammar(gb);
          gb.Culture = Thread.CurrentThread.CurrentCulture;
          recognizer.LoadGrammar(g);

          recognizer.SpeechRecognized +=
            new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
      }
      void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
      {
          if (e.Result.Text == "red")
          {
              Console.WriteLine("Recognized red color");
          }
      }
Posted
Updated 16-Jun-16 4:12am

1 solution

It has nothing to do with your code. This quality (fidelity) problem is a spectacular fallacy of the engine you are using. It does work if you pronounce everything very clearly and if your grammar is very small. Grow your grammar size a bit, introduce a couple of words which sounds even remotely similar, and… forget it. Ridiculously, the API includes dictation grammar, which apparently covers big part of the language thesaurus. This option is totally useless, no matter how good the user's pronunciation is.

It's noteworthy that, say, on Android you can install speech recognition as yet another keyboard. You can practically use speech input in dictation mode in several languages, with the fidelity which can really compete with on-screen virtual keyboards.

—SA
 
Share this answer
 
Comments
Member 12586674 17-Jun-16 5:45am    
Thanks Sergey.

I found another piece of code as below.

************

SpeechRecognitionEngine recognitionEngine = new SpeechRecognitionEngine();

recognitionEngine.SpeechRecognized += (s, args) =>
{
foreach (RecognizedWordUnit word in args.Result.Words)
{
if (word.Confidence >= 0.2f)
MessageBox.Show(word.Text);
}
};

************

I tried to play with "Cofidence" level but to no avail.

Is there any other way in which I can implement this functionality?
Sergey Alexandrovich Kryukov 17-Jun-16 9:16am    
Probably you already implemented it and cannot make the engine better. It does work, to certain extent. :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900