private void textBox_KeyDown(object sender , KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                open_config();
                if (textBox.Text == "你是谁的女朋友")
                {
                    source_text.Text = "我是" + Name_ + "可爱的女朋友";
                    textBox.Text = "";
                }

                else if (textBox.Text == "设置开机启动")
                {
                    textBox.Text = "";
                    open_autorun();
                }
                else if (textBox.Text == "设置关闭开机启动")
                {
                    textBox.Text = "";
                    delete_autorun();
                }
                else if (textBox.Text.IndexOf("称呼我为") > -1)
                {
                    Name_ = "";
                    Console.WriteLine(textBox.Text.Remove(0 , 4));
                    Name_ = textBox.Text.Remove(0 , 4);
                    create_config(Name_ , musicid_);
                    textBox.Text = "";
                    source_text.Text = "对您的称呼已更改," + Name_;
                }
                else if (textBox.Text == "录音测试")
                {
                    Talk_baidu baidu = new Talk_baidu();
                    // baidu.sound();
                    textBox.Text = "";
                }
                else if (textBox.Text == "录音开始")
                {
                    Talk_baidu baidu = new Talk_baidu();
                    baidu.luyin_on();
                    textBox.Text = "";
                }
                else if (textBox.Text == "录音停止")
                {
                    Talk_baidu baidu = new Talk_baidu();
                    //  baidu.luyin_save();
                    if (baidu.luyin_save())
                    {
                        httpRequest hR = new httpRequest();
                        string token_Access = hR.getStrAccess(hR.API_key , hR.API_secret_key);
                        string token_Text = hR.getStrText(hR.API_id , token_Access , "zh" , "1.wav" , "pcm" , "8000");
                        source_text.Text = token_Text;
                        // File.Delete("1.wav");
                    }
                    textBox.Text = "";
                }
                else
                {
                    source_text.Text = _talk.main(textBox.Text) + "\n\n我如此如此这般这般说道";
                    textBox.Text = "";
                }
            }
        }
Beispiel #2
0
        private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                open_config();
                if (textBox.Text == "你是谁的女朋友")
                {
                    source_text.Text = "我是" + Name_ + "可爱的女朋友";
                    textBox.Text     = "";
                }

                else if (textBox.Text == "设置开机启动")
                {
                    textBox.Text = "";
                    open_autorun();
                }
                else if (textBox.Text == "设置关闭开机启动")
                {
                    textBox.Text = "";
                    delete_autorun();
                }
                else if (textBox.Text.IndexOf("称呼我为") > -1)
                {
                    Name_ = "";
                    Console.WriteLine(textBox.Text.Remove(0, 4));
                    Name_ = textBox.Text.Remove(0, 4);
                    create_config(Name_, musicid_);
                    textBox.Text     = "";
                    source_text.Text = "对您的称呼已更改," + Name_;
                }
                else if (textBox.Text == "录音测试")
                {
                    Talk_baidu baidu = new Talk_baidu();
                    // baidu.sound();
                    textBox.Text = "";
                }
                else if (textBox.Text == "录音开始")
                {
                    Talk_baidu baidu = new Talk_baidu();
                    baidu.luyin_on();
                    textBox.Text = "";
                }
                else if (textBox.Text == "录音停止")
                {
                    Talk_baidu baidu = new Talk_baidu();
                    //  baidu.luyin_save();
                    if (baidu.luyin_save())
                    {
                        httpRequest hR           = new httpRequest();
                        string      token_Access = hR.getStrAccess(hR.API_key, hR.API_secret_key);
                        string      token_Text   = hR.getStrText(hR.API_id, token_Access, "zh", "1.wav", "pcm", "8000");
                        source_text.Text = token_Text;
                        // File.Delete("1.wav");
                    }
                    textBox.Text = "";
                }
                else
                {
                    source_text.Text = _talk.main(textBox.Text) + "\n\n我如此如此这般这般说道";
                    textBox.Text     = "";
                }
            }
        }