[C #] voice recognition - System.Speech

An interesting thing in the future may need them.

C # Speech Recognition: at namespace System.Speech SpeechSynthesizer can convert text to speech

 

Posted the code:

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();
        }
    }

 

Reproduced in: https: //www.cnblogs.com/Alenliu/p/3958199.html

Guess you like

Origin blog.csdn.net/weixin_34210740/article/details/93470048