C# Speech 中文发音 编程示例

您所在的位置:网站首页 中国的地理位置 C# Speech 中文发音 编程示例

C# Speech 中文发音 编程示例

#C# Speech 中文发音 编程示例| 来源: 网络整理| 查看: 265

我们要想实现中文发音或中文语音识别,必需先安装微软的Speech Application SDK(SASDK),它的最新版本是 SAPI 5.1 他能够识别中、日、英三种语言,你可以在这里下载:http://www.microsoft.com/speech/download/sdk51/, 需要安装这两个文件Speech SDK 5.1和5.1 Language Pack,其中5.1 Language Pack可以选择安装支持的语言。  安装好以后,我们就可以开始进行语音程序的开发了。

下面我们设计一个能够朗读中英文混合语言的类:

我们将用单例模式实现该类,类的代码如下,我们将详细解释:

public class Speach

{

  private static Speach _Instance = null ;

  private SpeechLib.SpVoiceClass voice =null;

  private Speach()

  {

BuildSpeach() ;

  }

public static Speach instance()

{

  if (_Instance == null)

_Instance = new Speach() ;

return _Instance ;

}

private void SetChinaVoice()

{

  voice.Voice = voice.GetVoices(string.Empty,string.Empty).Item(0) ;

}

private void SetEnglishVoice()

{

  voice.Voice = voice.GetVoices(string.Empty,string.Empty).Item(1) ;

}

private void SpeakChina(string strSpeak)

{

  SetChinaVoice() ;

  Speak(strSpeak) ;

}

private void SpeakEnglishi(string strSpeak)

{

  SetEnglishVoice() ;

  Speak(strSpeak) ;

}

public void AnalyseSpeak(string strSpeak)

{

  int iCbeg = 0 ;

  int iEbeg = 0 ;

  bool IsChina = true ;

  for(int i=0;i122||chr



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3