C#语言实现Windows系统下语音播报及语音识别
一、语音播报
语音播报可以使用System.Speech或Microsoft.Speech库文件来实现,但在Windows XP系统下运行时发现,调用System.Speech会报错,所以这里使用Microsoft.Speech来实现语音播报。
要实现语音播报还需要安装语音库(包括运行SDK和语音库),下载链接如下:
Microsoft Speech Platform SDK 11
zh-CN HuiHui中文
示例代码如下:
using Microsoft.Speech.Synthesis;
...
private SpeechSynthesizer speechSyn = new SpeechSynthesizer();
public void PlayAsync(string word)
{
var currentSpokenPrompt = speechSyn.GetCurrentlySpokenPrompt();
var speechSynthesizer = new SpeechSynthesizer();
var voices = speechSynthesizer.GetInstalledVoices(CultureInfo.CurrentCulture).Select