//声明一个委托
private delegate void SetTimerLogicCallback();
//声明一个定时器的类
private System.Threading.Timer threadTimer;
//执行委托的方法,ShowMemorandumInfo是查询数据库的方法
private void ThreadMethod(object obj)
{
SetTimerLogicCallback timerLogic = new SetTimerLogicCallback(ShowMemorandumInfo);
this.Invoke(timerLogic);
}
/// <summary>
/// 定时器设置,这个方法或者这段代码可以写在窗体加载的时候
/// </summary>
private void TimerSet()
{
threadTimer = new System.Threading.Timer(new System.Threading.TimerCallback(ThreadMethod), null, 0, 1000);
}
/// <summary>
/// 微软语音识别
/// </summary>
/// <param name="content">提示内容</param>
public static void SpeakAsync(string content)
{
try
{
if (synth != null)
synth.Dispose();
synth = new System.Speech.Synthesis.SpeechSynthesizer();
synth.SpeakAsyncCancelAll();
synth.SpeakAsync(content);
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 百度语音合成(文档网站:http://yuyin.baidu.com/docs/tts/197)
/// </summary>
private void BaiduTts(string audioText)
{
_ttsClient = new Baidu.Aip.Speech.Tts("API_KEY", "SECRET_KEY ");
// 可选参数
var option = new Dictionary<string, object>()
{
{"spd", 5}, // 语速
{"vol", 7}, // 音量
{"per", 4} // 发音人,4:情感度丫丫童声
};
var result = _ttsClient.Synthesis(audioText, option);
if (result.ErrorCode == 0)
{
string fileName = Application.StartupPath + "\\" + Guid.NewGuid().ToString() + ".mp3";
System.IO.File.WriteAllBytes(fileName, result.Data);
axWindowsMediaPlayer1.URL = fileName;
axWindowsMediaPlayer1.Ctlcontrols.play();
System.IO.File.Delete(fileName);
}
else
{
Utils.LogMessage("百度语音合成异常", result.ErrorMsg);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2026 源码网商城 (www.ymwmall.com) 版权所有