文字语音播报
实现语音播报,只需要引入“DotNetSpeech.dll”文件即可:
界面设计如下:

实现语音播报的基本源码如下:
sFlags某些属性值设置了会报错,直接使用默认的或者SVSFlagsAsync属性即可。
using DotNetSpeech;
using System;
using System.Windows.Forms;
namespace WindowsFormsApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            comboBox1.Items.AddRange(Enum.GetNames(typeof(SpeechVoiceSpeakFlags)));
            comboBox1.SelectedIndex = 0;
            textBox1.Text = "大家好,我是语音转换工具!";
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SpVoice sp = new SpVoice();
            SpeechVoiceSpeakFlags sFlags = (SpeechVoiceSpeakFlags)Enum.Parse(typeof(SpeechVoiceSpeakFlags), comboBox1.Text);
            sp.Voice = sp.GetVoices().Item(0);
            sp.Rate = 1; // 调整发音语速,可以为负数,如-3,0,5
            sp.Speak(textBox1.Text, sFlags);
        }
    }
}