开发软件以及运用程序集

VS C# winform
程序集 System.Speech.dll, v4.0.0.0

另作者也是小白,一起多多交流。
文字转语音保存音频和在线朗读-编程知识网

代码如下:

    public partial class Form1 : Form{private SpeechSynthesizer speech;public Form1(){InitializeComponent();}protected override void OnLoad(EventArgs e){speech= new SpeechSynthesizer();}/// <summary>/// 读/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void buttonRead_Click(object sender, EventArgs e){var rate = trackBarSpeed.Value;//语速var volume = trackBarVolumn.Value;//音量大小var text = textMsg.Text;//读取文字//开启线程Task.Run(() =>{speech.Rate = rate;speech.Volume = volume;speech.Speak(text);});}/// <summary>/// 暂停/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void buttonPause_Click(object sender, EventArgs e){speech.Pause();}/// <summary>/// 继续/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void buttonContinue_Click(object sender, EventArgs e){speech.Resume();}/// <summary>/// 录音/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void buttonRecord_Click(object sender, EventArgs e){var rate = trackBarSpeed.Value;//语速var volume = trackBarVolumn.Value;//音量大小var text = textMsg.Text;//读取文字SpeechSynthesizer speech= new SpeechSynthesizer();speech.Rate = rate;speech.Volume = volume;SaveFileDialog sfd = new SaveFileDialog();sfd.Filter = "Wave Files|*.wav";string Str= text.Substring(0,6);sfd.FileName = Str + "录音文件-作者QQ673071996.wav";speech.SetOutputToWaveFile(sfd.FileName);speech.Speak(textMsg.Text);speech.SetOutputToDefaultAudioDevice();MessageBox.Show("完成录音~~", "提示");}/// <summary>/// 关闭/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void buttonClose_Click(object sender, EventArgs e){Application.Exit();}}