添加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(); }
时间: 2024-11-07 11:20:05