C#实现语音合成功能
生活随笔
收集整理的这篇文章主要介绍了
C#实现语音合成功能
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
1、添加winfrom应用程序
2、添加语音合成引用 System.Speech
3、在winfrom窗体中添加控件,此处用了Button和textbox控件。
4、在代码中添加引用using System.Speech.Synthesis;
4、执行代码
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Speech.Synthesis;namespace WindowsFormsApplication1 {public partial class FrmVoiceSynthesis : Form{public FrmVoiceSynthesis(){InitializeComponent();}//实例化语音合成SpeechSynthesizer speech = new SpeechSynthesizer();//添加接收文本字段string text;private void button1_Click(object sender, EventArgs e){if (textBox1.Text != ""){text = textBox1.Text;}else{text = "请输入文字";}speech.Speak(text);}} }
总结
以上是生活随笔为你收集整理的C#实现语音合成功能的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 获取百度地图上某点的经纬度信息(百度地图
- 下一篇: C# 身份证号码15位和18位验证