/// <summary> /// rozpoczynamy rozpoznawanie /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button3_Click(object sender, EventArgs e) { //zmien WAV - na flac sox.Convert(TMP_WAVFILENAME, TMP_FLACFILENAME); //zinterpretuj FLAC RecognizeCommand(TMP_FLACFILENAME);//rozpoznaj polecenie if (SR == null) { return; } Google_Speech.SpeechInputResult.Hypothesis h = SR.getBestHypothesis(); switch (SR.status) { case 0: //OK MessageBox.Show("OK"); break; case 5: //błąd! MessageBox.Show("OK"); break; default: MessageBox.Show("wrong status"); break; } }
/// <summary> /// rozpoznaj polecenie z pliki audio(.flac) /// </summary> /// <param name="flac_FileName">plik flac z daymi audio</param> private bool RecognizeCommand(string flac_FileName) { try { SR = Google_Speech.ProcessFlacFile(flac_FileName, 16000, LANGUAGE, 10); } catch (Exception e) { Debug.Fail("RecognizeCommand() " + e.Message); } //FAIL! if (SR == null || SR.hypotheses.Count() == 0) { textBox4.Text = "fail"; textBox4.ForeColor = System.Drawing.Color.DarkRed; treeView1.Nodes.Clear(); return(false); } //SUCES textBox4.ForeColor = System.Drawing.Color.DarkGreen; //RAW JSON textBox3.Text = SR.json_mem; //--- //textBox nodes //------------------- treeView1.Nodes.Clear(); List <TreeNode> l = new List <TreeNode>(); l.Add(new TreeNode("staus: " + SR.status)); l.Add(new TreeNode("id: " + SR.ID)); List <TreeNode> l2 = new List <TreeNode>(); foreach (Google_Speech.SpeechInputResult.Hypothesis h in SR.hypotheses) { l2.Add(new TreeNode(h.ToString())); } l.Add(new TreeNode("hypothese (" + SR.hypotheses.Count() + ")", l2.ToArray())); TreeNode treeNode = new TreeNode("Google speech-api response", l.ToArray()); treeView1.Nodes.Add(treeNode); treeView1.ExpandAll(); //------------------- //best responese textBox4.Text = SR.getBestHypothesis().utterance + "@" + 100.0 * SR.getBestHypothesis().confidence + "%"; switch (SR.status) { case 0: treeView1.BackColor = System.Drawing.Color.GreenYellow; break; case 5: treeView1.BackColor = System.Drawing.Color.PaleVioletRed; break; default: MessageBox.Show("WTF?! zły status"); break; } //------------------ return(true); }
/// <summary> /// rozpoznaj polecenie z pliki audio(.flac) /// </summary> /// <param name="flac_FileName">plik flac z daymi audio</param> private bool RecognizeCommand(string flac_FileName) { try { SR = Google_Speech.ProcessFlacFile(flac_FileName, 16000, LANGUAGE, 10); } catch (Exception e) { Debug.Fail("RecognizeCommand() " + e.Message); } //FAIL! if(SR==null || SR.hypotheses.Count()==0) { textBox4.Text = "fail"; textBox4.ForeColor = System.Drawing.Color.DarkRed; treeView1.Nodes.Clear(); return false; } //SUCES textBox4.ForeColor = System.Drawing.Color.DarkGreen; //RAW JSON textBox3.Text = SR.json_mem; //--- //textBox nodes //------------------- treeView1.Nodes.Clear(); List<TreeNode> l = new List<TreeNode>(); l.Add(new TreeNode("staus: " + SR.status)); l.Add(new TreeNode("id: " + SR.ID)); List<TreeNode> l2 = new List<TreeNode>(); foreach (Google_Speech.SpeechInputResult.Hypothesis h in SR.hypotheses) { l2.Add(new TreeNode(h.ToString())); } l.Add(new TreeNode("hypothese (" + SR.hypotheses.Count() + ")", l2.ToArray())); TreeNode treeNode = new TreeNode("Google speech-api response", l.ToArray()); treeView1.Nodes.Add(treeNode); treeView1.ExpandAll(); //------------------- //best responese textBox4.Text = SR.getBestHypothesis().utterance + "@" + 100.0 * SR.getBestHypothesis().confidence + "%"; switch (SR.status) { case 0: treeView1.BackColor = System.Drawing.Color.GreenYellow; break; case 5: treeView1.BackColor = System.Drawing.Color.PaleVioletRed; break; default: MessageBox.Show("WTF?! zły status"); break; } //------------------ return true; }