void Recog_RecognitionSuccessful(object sender, RecognitionSuccessfulEventArgs e) { if (!FilterRecognised(e.ID, e.res)) { if (e.res.Confidence == 0.80f) { string path2 = @"C:\Users\ian\Desktop\audio\" + e.res.Text + "." + DateTime.Now.ToString("HHmmssff") + ".wav"; using (Stream outputStream = new FileStream(path2, FileMode.Create)) { e.res.WriteToWaveStream(outputStream); //outputStream.Close(); //Dispose via using } } return; } //TODO: This may need a cleanup string path = @"C:\Users\ian\Desktop\audio\" + e.res.Text + "." + DateTime.Now.ToString("HHmmssff") + ".wav"; using (Stream outputStream = new FileStream(path, FileMode.Create)) { e.res.Audio.WriteToWaveStream(outputStream); //outputStream.Close(); //Dispose via using } if (p != null) { p.RecogSuccessful(EndpointFromID(e.ID)); //play beep List<FIFOStream> fouts = p.GetOutputStreams(EndpointFromID(e.ID)); if (fouts == null || fouts.Count == 0) { Form1.updateLog("ERR: Couldn't find stream for remote: " + txtRemoteID.Text, ELogLevel.Error, ELogType.SpeechRecog | ELogType.Audio); } else { foreach (FIFOStream fout in fouts) { AudioOut.PlayWav(fout, @"C:\Users\ian\Desktop\beep3.wav"); } } } foreach (IControllable c in mControllables) { if (e.res.GrammarName == c.GetName()) if (c.OnSpeechRecognised(EndpointFromID(e.ID), e.res)) break; //first one to action } }
void CMUSphinx_Interop_RecognitionSuccessful(object sender, RecognitionSuccessfulEventArgs e) { OnRecognitionSuccessful(e.ID, e.res); }
void rec_RecognitionSuccessful(object sender, RecognitionSuccessfulEventArgs e) { if (!attempts.ContainsKey(e.ID)) { Form1.updateLog("ERR: Received recognition for non-existent query: " + e.ID, ELogLevel.Error, ELogType.SpeechRecog); return; } attempts[e.ID].Recognised(e.engine, e.res); }