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位验证