欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

教你如何用C#制作文字轉(zhuǎn)換成聲音程序

 更新時(shí)間:2014年09月04日 09:09:31   投稿:hebedich  
近突發(fā)奇想,想玩玩文字轉(zhuǎn)語音的東東,想了下思路,用C#簡(jiǎn)單實(shí)現(xiàn)了下,分享給大家,打算下面搞搞語音識(shí)別,下次分享給大家

教你如何用C#制作文字轉(zhuǎn)換成聲音程序

在System.Speech命名空間下,SpeechSynthesizer類可以把文字讀出來,一起來玩下~~

首先在Windows窗體項(xiàng)目中引入System.Speech。界面部分:

后臺(tái)代碼也很簡(jiǎn)單,只不過調(diào)用了SpeechSynthesizer類的一些方法:

using System.Windows.Forms;
using System.Speech;
using System.Speech.Synthesis;
namespace WindowsFormsApplication1
{
  public partial class Form1 : Form
  {
    private SpeechSynthesizer ss;
    public Form1()
    {
      InitializeComponent();
    }
    private void Form1_Load(object sender, EventArgs e)
    {
      ss = new SpeechSynthesizer();
    }
    private void buttonRead_Click(object sender, EventArgs e)
    {
      ss.Rate = trackBarSpeed.Value;
      ss.Volume = trackBarVolumn.Value;
      ss.SpeakAsync(txtMsg.Text);
    }
    private void buttonPause_Click(object sender, EventArgs e)
    {
      ss.Pause();
    }
    private void buttonContinue_Click(object sender, EventArgs e)
    {
      ss.Resume();
    }
    private void buttonRecord_Click(object sender, EventArgs e)
    {
      SpeechSynthesizer ss = new SpeechSynthesizer();
      ss.Rate = trackBarSpeed.Value;
      ss.Volume = trackBarVolumn.Value;
      SaveFileDialog sfd = new SaveFileDialog();
      sfd.Filter = "Wave Files|*.wav";
      ss.SetOutputToWaveFile(sfd.FileName);
      ss.Speak(txtMsg.Text);
      ss.SetOutputToDefaultAudioDevice();
      MessageBox.Show("完成錄音~~","提示");
    }
    private void buttonClose_Click(object sender, EventArgs e)
    {
      Application.Exit();
    }
  }
}

相關(guān)文章

最新評(píng)論