C# 文字转声音

时间:2021-11-01 09:13:01

添加COM组件引用:Microsoft Speech object library

        private SpVoice voice;
private void button1_Click(object sender, EventArgs e)
{
voice = new SpVoice();
voice.Rate = 0;
voice.Volume = 100;
voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync); } private void button2_Click(object sender, EventArgs e)
{
voice.Pause();
} private void button3_Click(object sender, EventArgs e)
{
voice.Resume();
}