void SayPL(string text) { try{ string tmp_mp3 = "a.mp3"; if (IsFileLocked(tmp_mp3)) { tmp_mp3 = "a1.mp3"; } Google_Speech.Say(text, tmp_mp3, "pl"); ExecuteCommandSync(tmp_mp3); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
/// <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); }