.NET语音转文字文字转语音
原创文本转语音
这比较简单,只是引用COM中的 Microsoft Speech objcet Library

using SpeechLib; public ActionResult speak(string speechSounds) { SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpVoice spVoice = new SpVoice(); spVoice.Rate = spVoice.Rate - 5; if (spVoice.Volume < 100) { spVoice.Volume = spVoice.Volume + 10; }
if (spVoice.Volume > 9)
{
spVoice.Volume = spVoice.Volume - 10;
}
spVoice.Speak(speechSounds, SpFlags);
return Content("成功");
}

文本生成的语音文件
在程序集中引用 System.Speech

using System.Speech.Synthesis;
private SpeechSynthesizer synth = null;
///

语音转文本

using System.Speech.Recognition;
private SpeechRecognitionEngine SRE = new SpeechRecognitionEngine();
///
///
/// 确定语音并将其转换为需要输出的文本
///
///
///
private void G\_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
string result = e.Result.Text;
string RetSpeck = string.Empty;
switch (result)
{
case "时间":
RetSpeck = "您输入了时间";
break;
case "电话":
RetSpeck = "您输入了电话号码";
break;
case "短信":
RetSpeck = "您输入了短信";
break;
case "定位":
RetSpeck = "您输入了位置";
break;
case "天气":
RetSpeck = "你输入了天气";
break;
case "帮助":
RetSpeck = "您输入了帮助";
break;
}
speak(RetSpeck);
}
转自:https://www.cnblogs.com/-maomao/p/6861447.html
版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除
itfan123





