Getting SpeechRecognitionEngine to detect audio

  • Thread starter Thread starter cnathaide
  • Start date Start date
C

cnathaide

Hi,

I am trying out the new Speech features in the System.Speech
namespace. I still have Windows Server 2003 on my machine.

Here is what I would like to do. I am trying to write a program that
takes a *.wav file and automatically transcribes it. Here is where I
am having trouble. I do not know whether the speech recognition engine
is recognizing any text. In other words, at what point in the code
does the file start playing?

Here is my code:

using System.Speech.Synthesis;
using System.Speech.Recognition;

SpeechRecognitionEngine SRE = new SpeechRecognitionEngine();
DictationGrammar dg = new DictationGrammar();

SRE.LoadGrammar(dg);;
SRE.SetInputToWaveFile(@"C:\SampleApp\Sample.wav");;
SRE.RecognizeAsync();;
SRE.SpeechDetected +=
new EventHandler<SpeechDetectedEventArgs>(SRE_SpeechDetected);
SRE.SpeechRecognized += new
EventHandler<SpeechRecognizedEventArgs>(SRE_SpeechRecognized);
AudioState state = SRE.AudioState; // This shows AudioState.Stopped

void SRE_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result != null)
{
Console.WriteLine(e.Result.Text)
}
}


How do I get the program to start reading the *.wav file and write the
output to the Console??

I appreciate any help in this matter.

Regards

Chris
 
Hi,

I am trying out the new Speech features in the System.Speech
namespace. I still have Windows Server 2003 on my machine.

Here is what I would like to do. I am trying to write a program that
takes a *.wav file and automatically transcribes it. Here is where I
am having trouble. I do not know whether the speech recognition engine
is recognizing any text. In other words, at what point in the code
does the file start playing?

Here is my code:

using System.Speech.Synthesis;
using System.Speech.Recognition;

SpeechRecognitionEngine SRE = new SpeechRecognitionEngine();
DictationGrammar dg = new DictationGrammar();

SRE.LoadGrammar(dg);;
SRE.SetInputToWaveFile(@"C:\SampleApp\Sample.wav");;
SRE.RecognizeAsync();;
SRE.SpeechDetected +=
new EventHandler<SpeechDetectedEventArgs>(SRE_SpeechDetected);
SRE.SpeechRecognized += new
EventHandler<SpeechRecognizedEventArgs>(SRE_SpeechRecognized);
AudioState state = SRE.AudioState; // This shows AudioState.Stopped

void SRE_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
if (e.Result != null)
{
Console.WriteLine(e.Result.Text)

}
}

How do I get the program to start reading the *.wav file and write the
output to the Console??

I appreciate any help in this matter.

Regards

Chris

I'm not familiar with the API, but looking at the doc's on
RecognizeAsync, might it be because you're hooking up the events after
calling RecognizeAsync?
 
Back
Top