private void back_Click(object sender, EventArgs e) { this.Hide(); mainmenu hey = new mainmenu(); hey.Show(); }
private void match_enq() { try { con = new SqlCeConnection(@"Data Source=C:\Users\RnBz\Documents\Visual Studio 2012\Projects\Speech Recognition2\SpeechRecognition\bin\Debug\icers.sdf"); con.Open(); SqlCeDataAdapter da = new SqlCeDataAdapter("select distinct(sel_id) from matches where enq_id=" + enq_check, con); DataTable dt= new DataTable(); da.Fill(dt); if(dt.Rows.Count==0) { obj.SpeakAsync("I can not Finf any matching results..."); Thread.Sleep(1500); } else { foreach (DataRow row in dt.Rows) { int sel_id = int.Parse(row["sel_id"].ToString()); Console.WriteLine(row["sel_id"].ToString()); SqlCeDataAdapter da1 = new SqlCeDataAdapter("select * from sellers where id="+sel_id, con); DataTable dt_sel = new DataTable(); da1.Fill(dt_sel); recognizer = new SpeechRecognitionEngine(); recognizer.RecognizeAsyncStop(); GrammarBuilder gb = new GrammarBuilder(); Choices id = new Choices(); foreach (DataRow row2 in dt_sel.Rows) { obj.SpeakAsync("Unique ID "+row2["id"].ToString()+": "+row2["title"].ToString()); obj.SpeakAsync(",Contact Number... : " + row2["contact"].ToString()); obj.SpeakAsync("I repeat: " + row2["contact"].ToString()); id.Add(row2["id"].ToString()); } gb.Append(id); // Create the Grammar instance and load it into the speech recognition engine. Grammar g = new Grammar(gb); recognizer.LoadGrammar(g); recognizer.SetInputToDefaultAudioDevice(); while (recognizer.AudioState.Equals( AudioState.Speech)) { Thread.Sleep(100); } } } Thread.Sleep(500); obj.SpeakAsync("Thank you for using my help, Please come back again....."); Thread.Sleep(4000); mainmenu hey = new mainmenu(); hey.Show(); this.Close(); } catch (Exception ea) { Console.WriteLine(ea.Message); obj.SpeakAsync("I can not find any such results, Please try another enquiry..."); Thread.Sleep(5000); check_enq(); } finally { con.Close(); } }