4

I would like to know how to down microphone sensitivity with System.Speech in C#..

To explain myself, i have a grammar file, and my application should begin to record me when i say SIVRAJ (my program's name)

However, i can say something TOTALLY different, and my application will understand something 'SIVRAJ'...

There is a part from my XML file :

<rule id="mouskie" scope="public">
<item>
  <one-of>
    <item>SIVRAJ</item>
  </one-of>
</item>
<ruleref special="GARBAGE" />
<one-of>
  <item>
    <one-of>
      <item>quit</item>
    </one-of>
    <tag>$.mouskie={}; $.mouskie._value="QUIT";</tag> // quit programm when i say SIVRAJ + quit
  </item>
  ..... etc etc

And this is the function which start Recognition Engine :

SrgsDocument xmlGrammar = new SrgsDocument("Grammaire.grxml");
Grammar grammar = new Grammar(xmlGrammar);
ASREngine = new SpeechRecognitionEngine();
ASREngine.SetInputToDefaultAudioDevice();
ASREngine.LoadGrammar(grammar);

ASREngine.SpeechRecognized += ASREngine_SpeechRecognized;
ASREngine.SpeechRecognitionRejected += ASREngine_SpeechRecognitionRejected;
ASREngine.SpeechHypothesized += ASREngine_SpeechHypothesized;

Finally, i recover data here :

 recoText.Text = e.Result.Text;
 devine.Text = "";
 affiche.Text = "";

 string baseCommand = e.Result.Semantics["mouskie"].Value.ToString();
 commandText.Text = baseCommand;

 if (baseCommand.Equals("QUIT"))
 {
   m_SpeechSynth.Speech("au revoir", VoiceGender.Male, VoiceAge.Adult);
   Environment.Exit(0);
 }
Filburt
  • 17,626
  • 12
  • 64
  • 115
bastien
  • 41
  • 2

1 Answers1

2

In this scenario you really are not looking for microphone sensitivity. What I believe you are looking for is phrase confidence.

When the engine returns a recognition results it also returns a confidence score along with it. "Basically saying this is how confident I am that what I heard was what you said."

if (Speech.Recognition.RecognitionResult.Confidence > .20)
{
    //do some good stuff
}
else
{
   // ignore
}

This contains a value from 0 to 1 with 1 being the most confident and 0 basically being background noise causing reco events. You will have to play around with what confidence value makes sense since it is highly grammar and environment specific.

Another thing you could do is change the trigger word. I doubt the lexicon for the speech engine has the phrase SIVRAJ in it. In this case the engine will try and make a guess as to what phonemes make up this word (you can supply them yourself in the grammar as a custom pronunciation if you have a linguistic background). Something like Start Recording will have a better chance to give you a more decent experience.

Matt Johnson
  • 1,913
  • 16
  • 23