//This will take the recorded speech and compare it against the expected string //INPUT: expectedString //OUPUT: True if the strings match, false if not private Boolean doSpeechTextValidation(string expectedString) { speechRecognition_system_speech ps = new speechRecognition_system_speech(); functionResult f = ps.convertToSpeechWithString(audioStream1, expectedString); if (f.Result == true) { //If no recognised result, then no valid phrase if found. this is NOT an error if (f.recognitionResult == null) { txtRecognisedText.Text = "No Valid Phrase Found, Please try again ensuring to speak slowly and clearly"; txtRecognisedText.BackColor = Color.Salmon; return(false); } else { txtRecognisedText.Text = f.recognitionResult.Text + " (Result Confidence = " + f.recognitionResult.Confidence + ")"; txtRecognisedText.BackColor = Color.LightGreen; return(true); } } else { MessageBox.Show(f.Message, "doSpeechTextValidation - Error"); return(false); } }
//This will do the speech validation functionality //INPUT: //OUPUT: true for valid command found private Boolean doSpeechTextValidation() { speechRecognition_system_speech ps = new speechRecognition_system_speech(); Choices c = new Choices(); //Now build a list of choices foreach (DataGridViewRow dr in dgvUserAccounts.Rows) { string keyword = dr.Cells["SiteKey"].Value.ToString(); //Generate a list of available commands c.Add("Open " + keyword); } functionResult f = ps.convertToSpeechwithChoices(audioStream1, c); if (f.Result == true) { if (f.recognitionResult == null) { txtTextRecognises.Text = "No Valid Phrase Found, Please try again ensuring to speak slowly and clearly"; return(false); } else { txtTextRecognises.Text = f.recognitionResult.Text + " (Result Confidence = " + f.recognitionResult.Confidence + ")"; return(true); } } else { MessageBox.Show(f.Message, "doSpeechTextValidation - Error"); return(false); } }
private void btnConvertToText_Click(object sender, EventArgs e) { speechRecognition_system_speech s = new speechRecognition_system_speech(); //MessageBox.Show(s.convertToSpeech(audioStream1, null)); }