明天的明天 永远的永远 未知的一切 我与你一起承担 ??

是非成败转头空 青山依旧在 几度夕阳红 。。。
  博客园  :: 首页  :: 管理

C# -数字语音wav 提示。。。。。。。。。。。

Posted on 2009-04-09 19:33  且行且思  阅读(1108)  评论(0编辑  收藏  举报

https://files.cnblogs.com/Fooo/Net-数字语音wav.rar

 

https://files.cnblogs.com/Fooo/wav.rar

 

 

///////////***************************

using System.Media;

 

 

 

 

       SoundPlayer win;
        public Form1()
        {
            InitializeComponent();
        }

 

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            win = null;
            int keyAscii = (int)e.KeyChar;
            this.label1.Text = keyAscii.ToString();
            switch (keyAscii)
            {
               //win = new SoundPlayer(Application.StartupPath + @"\2.wav");  //相对路径写法 
                case 48:
                    win=new SoundPlayer(Properties.Resources._0);
                    break;
                case 49:
                    win = new SoundPlayer(Properties.Resources._1);                  
                    break;
                case 50:
                    win = new SoundPlayer(Properties.Resources._2);
                    break;
                case 51:
                    win = new SoundPlayer(Properties.Resources._3);
                    break;
                case 52:
                    win = new SoundPlayer(Properties.Resources._4);
                    break;
                case 53:
                    win = new SoundPlayer(Properties.Resources._5);
                    break;

                case 54:
                    win = new SoundPlayer(Properties.Resources._6);
                    break;
                case 55:
                    win = new SoundPlayer(Properties.Resources._7);
                    break;
                case 56:
                    win = new SoundPlayer(Properties.Resources._8);
                    break;
                case 57:
                    win = new SoundPlayer(Properties.Resources._9);
                    break;
                default:
                    break;

            }
            if (win != null)
            win.Play();
        }