by Pooja Mathur on Tuesday, January 13th - 6:50 PM
Hello everyone,
I'm working on a research project that takes the audio stream from over the network (I'm using Skype and the Skype4COM library). I have the stream and I'm setting the stream as input for the speech recognizer. When I run the program, the call to skype is made. Once the call is in progress the recognizer starts, AudioState goes into "silence". It gets maybe a second of data from the stream and then the state changes into "stopped" and the "recognize completed" event occurs. During that time the stream gets about 20000 bytes of information. Does anyone know why the recognizer would think it's done?
Here is my code for the listener. I actually have all event listeners in my code, but they just print out to the console, so I left them out. In another class, I get the stream from Skype and I take each byte and write it to the memory stream in the class below. (sl.memStrm.WriteByte(**byteFromNetworkStream**);
class SkypeListener {
SpeechRecognitionEngine recognizer = null;
DictationGrammar dictationGrammar = null;
SpeechAudioFormatInfo audioFormat = null;
TextWriter tw = null;
public MemoryStream memStrm = new MemoryStream();
public SkypeListener()
{
dictationGrammar = new DictationGrammar();
recognizer = new SpeechRecognitionEngine();
audioFormat = new SpeechAudioFormatInfo(44100, AudioBitsPerSample.Sixteen, AudioChannel.Mono);
}
public void startListener()
{
try {
recognizer.SetInputToAudioStream((Stream)memStrm, audioFormat);
recognizer.LoadGrammar(dictationGrammar);
recognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(recognizer_SpeechRecognized);
recognizer.AudioStateChanged += new EventHandler<AudioStateChangedEventArgs>(recognizer_AudioStateChanged);
recognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(recognizer_RecognizeCompleted);
recognizer.RecognizeAsync(RecognizeMode.Multiple);
System.Console.WriteLine("Length of buffer: " + memStrm.Length);
} catch (Exception e) {
System.Console.WriteLine("Error - speech listener: " + e);
}
}
void recognizer_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
tw = new StreamWriter("transcribeSig.txt");
tw.WriteLine(e.Result.Text);
tw.Close();
Console.WriteLine(e.Result.Text);
}
void recognizer_RecognizeCompleted(object sender, RecognizeCompletedEventArgs e)
{
Console.WriteLine("RECOG COMPLETE!!");
}
void recognizer_AudioStateChanged(object sender, AudioStateChangedEventArgs e)
{
Console.WriteLine("AUDIO STATE CHANGED: " + recognizer.AudioState);
}
}
I would appreciate any insights, thanks.
Pooja