1

I have been messing around with C# voice to text which has been pretty easy. However I am trying to figure out how I can detect a candid sentence versus looking from the preset commands I've made.

Currently I can do various things by listening for keywords:

SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine();
public Form1()
{
   _recognizer.SetInputToDefaultAudioDevice();
   _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(File.ReadAllLines(@"Commands.txt")))));
   _recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(_recognizer_SpeechRecognized);
   _recognizer.RecognizeAsync(RecognizeMode.Multiple);
}

void _recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
   //magic happens here
}

This works great as I said before. I've tried to use some of the other functions associated with speech recognition such as SpeechHypothesized but it will only guess words based on the grammar loaded into the program which are preset commands. This makes sense. However if I load a full library into the grammar then my commands will be much less accurate.

I am trying to setup the program so when a keyword is said (one of the commands) it will listen to try to transcribe an actual sentence.

Nick
  • 9,285
  • 33
  • 104
  • 147
  • Found some decent information [here](http://michal.is/blog/speech-recognition-with-c-dictation-and-custom-grammar/). I was looking for "Speech Dictation" although the speech to text is not very accurate even with setting word accuracy. – Nick Nov 27 '13 at 19:45
  • Duplicate of http://stackoverflow.com/questions/10377054/how-to-recognize-a-phrase-from-a-voice-file/10379351#10379351 – Nikolay Shmyrev Nov 30 '13 at 01:05

1 Answers1

0

I was looking for "Speech Dictation." Instead of loading my command list into the grammar I was able to use DictationGrammar() that was built into c# in order to listen for a complete sentence.

SpeechRecognitionEngine recognitionEngine recognitionEngine = new SpeechRecognitionEngine();
recognitionEngine.SetInputToDefaultAudioDevice();
recognitionEngine.LoadGrammar(new DictationGrammar());
RecognitionResult result = recognitionEngine.Recognize(new TimeSpan(0, 0, 20));
foreach (RecognizedWordUnit word in result.Words)
{
     Console.Write(“{0} “, word.Text);
}

Although this method doesn't seem very accurate even if I use the word.Confidence it seems only to guess the correct word less than half the time.

May try to use the Google Voice API to send flac file for post processing.

Nick
  • 9,285
  • 33
  • 104
  • 147