WIN10专业版环境
using SpeechLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApp4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Voice.SpeekText("这是一个测试语音");
}
}
public class Voice
{
public static void SpeekText(string strContent)
{
try
{
SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
SpVoice Voice = new SpVoice();
int iVer = 0;//女生
Voice.Voice = Voice.GetVoices(string.Empty, string.Empty).Item(iVer);
Voice.Speak(strContent, SpFlags);
Voice.WaitUntilDone(5000);
}
catch
{
throw;
}
}
}
选择男声女声还可以通过控制面板->语音识别->文本到语音转换