请问如何在程序中设置微软语音识别引擎? 感觉你用的不是System.Speech呢?Speech里没有CreateRecoContext()的.ActiveObject里的"SAPI.SpSharedRecognizer"到是有.如果你用的是这个是不是要先Stop呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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(0); } 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; i < strSpeak.Length; i++) { char chr = strSpeak[i]; if (IsChina) { if (chr <= 122 && chr >= 65) { int iLen = i - iCbeg; string strValue = strSpeak.Substring(iCbeg, iLen); SpeakChina(strValue); iEbeg = i; IsChina = false; } } else { if (chr > 122 || chr < 65) { int iLen = i - iEbeg; string strValue = strSpeak.Substring(iEbeg, iLen); this.SpeakEnglishi(strValue); iCbeg = i; IsChina = true; } } }//end for if (IsChina) { int iLen = strSpeak.Length - iCbeg; string strValue = strSpeak.Substring(iCbeg, iLen); SpeakChina(strValue); } else { int iLen = strSpeak.Length - iEbeg; string strValue = strSpeak.Substring(iEbeg, iLen); SpeakEnglishi(strValue); } } private void BuildSpeach() { if (voice == null) voice = new SpVoiceClass(); } public int Volume { get { return voice.Volume; } set { voice.SetVolume((ushort)(value)); } } public int Rate { get { return voice.Rate; } set { voice.SetRate(value); } } private void Speak(string strSpeack) { try { voice.Speak(strSpeack, SpeechVoiceSpeakFlags.SVSFlagsAsync); } catch (Exception err) { throw (new Exception("发生一个错误:" + err.Message)); } } public void Stop() { voice.Speak(string.Empty, SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); } public void Pause() { voice.Pause(); } public void Continue() { voice.Resume(); } }//end class 有没有尝试过microsoft agent可以自己选择喜欢的tts等组件 未能加载文件或程序集“PDFLibNet.dll”或它的某一个依赖项。找不到指定的模块。 关于新浪微博的定向发微博(分组) C# 调用 c++ DLL P/invoke 字符串封送的错误 关于不同xp主题的精确坐标问题 C# 数字签名问题 智能客户端需要学习哪些技术? 请问在PPC,smartphone,symbian中有没有系统预装的数据库? 在WEB页面中调用启动另一个应用程序 谁给个vs2005和sql2005的下载地址我(简体中文版) 谁要分? 一段IBM大连分公司的随机面试卷子 求c#代码实例完整版的(免费的那种)
{
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(0); }
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; i < strSpeak.Length; i++)
{
char chr = strSpeak[i];
if (IsChina)
{
if (chr <= 122 && chr >= 65)
{
int iLen = i - iCbeg;
string strValue = strSpeak.Substring(iCbeg, iLen);
SpeakChina(strValue);
iEbeg = i;
IsChina = false;
}
}
else
{
if (chr > 122 || chr < 65)
{
int iLen = i - iEbeg;
string strValue = strSpeak.Substring(iEbeg, iLen);
this.SpeakEnglishi(strValue);
iCbeg = i;
IsChina = true;
}
}
}//end for
if (IsChina)
{
int iLen = strSpeak.Length - iCbeg;
string strValue = strSpeak.Substring(iCbeg, iLen);
SpeakChina(strValue);
}
else
{
int iLen = strSpeak.Length - iEbeg;
string strValue = strSpeak.Substring(iEbeg, iLen);
SpeakEnglishi(strValue);
}
}
private void BuildSpeach()
{
if (voice == null)
voice = new SpVoiceClass();
}
public int Volume
{
get
{
return voice.Volume;
}
set
{
voice.SetVolume((ushort)(value));
}
} public int Rate
{
get
{
return voice.Rate;
}
set
{
voice.SetRate(value);
}
}
private void Speak(string strSpeack)
{
try
{
voice.Speak(strSpeack, SpeechVoiceSpeakFlags.SVSFlagsAsync);
}
catch (Exception err)
{
throw (new Exception("发生一个错误:" + err.Message));
}
}
public void Stop()
{
voice.Speak(string.Empty, SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak);
}
public void Pause()
{
voice.Pause();
}
public void Continue()
{
voice.Resume();
} }//end class
可以自己选择喜欢的tts等组件