在c#中的语音合成与识别技术new

在c#中的语音合成与识别技术new

ID:20035393

大小:80.45 KB

页数:7页

时间:2018-10-09

在c#中的语音合成与识别技术new_第1页
在c#中的语音合成与识别技术new_第2页
在c#中的语音合成与识别技术new_第3页
在c#中的语音合成与识别技术new_第4页
在c#中的语音合成与识别技术new_第5页
资源描述:

《在c#中的语音合成与识别技术new》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、在.net中,对英文语音有较好的支持,但是对中文语音的支持还没有加入进来,我们要想实现中文发音或中文语音识别,必需先安装微软的SpeechApplicationSDK(SASDK),它的最新版本是SAPI5.1他能够识别中、日、英三种语言,你可以在这里下载:http://www.microsoft.com/speech/download/sdk51/,需要安装这两个文件SpeechSDK5.1和5.1LanguagePack,其中5.1LanguagePack可以选择安装支持的语言。  安装好以后,我们就可以开始进行语音程序的开发了,当然,在这之前我们需要把SAPI.dll通过如下

2、图所示添加到引用中  下面我们设计一个能够朗读中英文混合语言的类:  我们将用单例模式实现该类,类的代码如下,我们将详细解释:publicclassSpeach{ privatestaticSpeach_Instance=null; privateSpeechLib.SpVoiceClassvoice=null; privateSpeach() {  BuildSpeach(); }publicstaticSpeachinstance(){ if(_Instance==null)  _Instance=newSpeach();  return_Instance;}privatevo

3、idSetChinaVoice(){ voice.Voice=voice.GetVoices(string.Empty,string.Empty).Item(0);}privatevoidSetEnglishVoice(){ voice.Voice=voice.GetVoices(string.Empty,string.Empty).Item(1);}privatevoidSpeakChina(stringstrSpeak){ SetChinaVoice(); Speak(strSpeak);}privatevoidSpeakEnglishi(stringstrSpeak){ Se

4、tEnglishVoice(); Speak(strSpeak);}publicvoidAnalyseSpeak(stringstrSpeak){ intiCbeg=0; intiEbeg=0; boolIsChina=true; for(inti=0;i=65)   {    intiLen=i-iCbeg;    stringstrValue=strSpeak.Substring(iCbeg,iLen);    Spe

5、akChina(strValue);    iEbeg=i;    IsChina=false;   }  }  else  {   if(chr>122

6、

7、chr<65)   {    intiLen=i-iEbeg;    stringstrValue=strSpeak.Substring(iEbeg,iLen);    this.SpeakEnglishi(strValue);    iCbeg=i;    IsChina=true;   }  } }//endfor if(IsChina) {  intiLen=strSpeak.Length-iCbeg;  strings

8、trValue=strSpeak.Substring(iCbeg,iLen);  SpeakChina(strValue); } else {  intiLen=strSpeak.Length-iEbeg;  stringstrValue=strSpeak.Substring(iEbeg,iLen);  SpeakEnglishi(strValue); }}privatevoidBuildSpeach(){ if(voice==null)  voice=newSpVoiceClass();}publicintVolume{ get {  returnvoice.Volume; } 

9、set {  voice.SetVolume((ushort)(value)); }}publicintRate{ get {  returnvoice.Rate; } set {  voice.SetRate(value); }}privatevoidSpeak(stringstrSpeack){ try {  voice.Speak(strSpeack,SpeechVoiceSpeakFlags.SVSFlagsAsync); } catch(Exceptione

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。