首先项目添加引用。 System.Speech.DLL
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Threading;
using System.Speech.Synthesis; private void Button1_Click(object sender, EventArgs e)
{
SpeechSynthesizer synth = new SpeechSynthesizer(); //获取本机上所安装的所有的Voice的名称
string voicestring = ""; foreach (InstalledVoice iv in synth.GetInstalledVoices())
{
voicestring += iv.VoiceInfo.Name + ",";
} synth.Volume = 100;
synth.Rate = -5;
//根据Voice的name属性确定要使用的Voice
synth.SelectVoice("Girl XiaoKun");
//根据文字内容合成语音
synth.Speak("你好");
} synth.SelectVoice("Girl XiaoKun"); 这里报错
报错信息为 "不能设置语音。未安装匹配的语音,或语音被禁用。"
有做过的来谢谢帮忙
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Threading;
using System.Speech.Synthesis; private void Button1_Click(object sender, EventArgs e)
{
SpeechSynthesizer synth = new SpeechSynthesizer(); //获取本机上所安装的所有的Voice的名称
string voicestring = ""; foreach (InstalledVoice iv in synth.GetInstalledVoices())
{
voicestring += iv.VoiceInfo.Name + ",";
} synth.Volume = 100;
synth.Rate = -5;
//根据Voice的name属性确定要使用的Voice
synth.SelectVoice("Girl XiaoKun");
//根据文字内容合成语音
synth.Speak("你好");
} synth.SelectVoice("Girl XiaoKun"); 这里报错
报错信息为 "不能设置语音。未安装匹配的语音,或语音被禁用。"
有做过的来谢谢帮忙
解决方案 »
- 这个网站的源代码怎么去取?从来没有见过这样的,各位遇到过吗
- 关于新闻抓取
- 强制浏览器跳转页面
- <winform A窗体删除B窗体listbox的值,不刷新小问题 >
- 还是关于webBrowser控件的问题,这次只要解决,分全给他
- 请教高手一个问题,急~~~~~~~~~~~~
- 请问一下:下面网址的网站是用的什么名字的系统啊?哪里有下载的啊?能不能给个下载的网址啊?谢谢!(我看见很多网站都用的这种类似的系
- 如何从一个aspx网站中post数据
- 大家快加入2846761java火拼.net&ruby
- 入门问题: C#是语言还是环境?是VS。NET中的东西吗?
- Socket超时问题
- ls_RevceDate什么意思
你看一下VoiceInfo.Name 默认有Microsoft Sam
SpeechSynthesizer synth = new SpeechSynthesizer(); //获取本机上所安装的所有的Voice的名称
string voicestring = ""; foreach (InstalledVoice iv in synth.GetInstalledVoices())
{
voicestring += iv.VoiceInfo.Name + ",";
} synth.Volume = 100;
synth.Rate = -5;
//根据Voice的name属性确定要使用的Voice
synth.SelectVoice("Microsoft Sam");
//根据文字内容合成语音
synth.Speak("你好");
如果不选择 SelectVoice 则是可以的而且不会出错。
默认win7 下是Lili的声音。
XP下是 Microsoft Sam
using System.Speech.Synthesis;
兄弟这个从3.0就封起来了。
所以不存在需要安装什么SDK .
现在就是掉用 SelectVoice 就出 不能设置语音。未安装匹配的语音,或语音被禁用。 XP win 7下都一样。如我们不调用这个SelectVoice 方法 就是默认系统自带的声音。
XP很难听的。
在XP下页可以做测试就是调用SelectVoice 方法赋值就报错。不调用就是默认的声音。XP很难听的。