码迷,mamicode.com
首页 > 其他好文 > 详细

[语音识别]System.Speech

时间:2014-09-05 17:37:11      阅读:265      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   ar   for   2014   art   div   代码   

一个有趣的东西,今后可能用得上。

C#语音识别:在命名空间 System.Speech下SpeechSynthesizer可以将文字转换成语音

 

bubuko.com,布布扣

贴出代码:

public partial class Form1 : Form
    {
        private SpeechSynthesizer ss;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ss = new SpeechSynthesizer();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ss.Rate = trackbarSpeed.Value;
            ss.Volume = trackbarVoice.Value;
            ss.SpeakAsync(txtSpeechText.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ss.Pause();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            ss.Resume();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            SpeechSynthesizer ss = new SpeechSynthesizer();
            ss.Rate = trackbarSpeed.Value;
            ss.Volume = trackbarVoice.Value;
            SaveFileDialog savefd = new SaveFileDialog();
            savefd.Filter = "wave Files|*.wav";
            ss.SetOutputToWaveFile(savefd.FileName);
            ss.Speak(txtSpeechText.Text);
            ss.SetOutputToDefaultAudioDevice();
            MessageBox.Show("完成录音~~~", "提示");
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }

 

[语音识别]System.Speech

标签:blog   http   io   ar   for   2014   art   div   代码   

原文地址:http://www.cnblogs.com/shzalen/p/3958199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!