还是把代码贴上来吧,主要代码如下:

 

privateSpeechSynthesizersynth=null;//语音对象
///<summary>
///返回一个SpeechSynthesizer对象
///</summary>
///<returns></returns>
privateSpeechSynthesizerGetSpeechSynthesizerInstance()
{
if(synth==null)
{
synth=newSpeechSynthesizer();
}
returnsynth;
}
///<summary>
///获得朗读设置对象
///</summary>
///<returns></returns>
privateVoiceClassGetVoiceClass()
{
VoiceClasssetViceClass=newVoiceClass();
setViceClass.VoiceName=cboTokens.Text;
setViceClass.Rate=int.Parse(cboSpeed.Text);
setViceClass.Volume=tbVoice.Value;
setViceClass.VoiceText=txtInput.Text;
returnsetViceClass;
}
///<summary>
///播放
///</summary>
///<paramname="sender"></param>
///<paramname="e"></param>
privatevoidbtnGo_Click(objectsender,EventArgse)
{
if(IsVaild())
{
VoiceClasssetViceClass=GetVoiceClass();//VoiceClass是自己建立的一个类,里面封转了语速音量播放人播放文本
Threadthread=newThread(RingVoice);
thread.Start(setViceClass);
}
}
///<summary>
///开始朗读放在线程中
///</summary>
///<paramname="VoiceObject"></param>
publicvoidRingVoice(objectVoiceObject)
{
try
{
VoiceClassvoiceClass=(VoiceClass)VoiceObject;
synth=GetSpeechSynthesizerInstance();
synth.SelectVoice(voiceClass.VoiceName);
synth.Rate=voiceClass.Rate;
synth.Volume=voiceClass.Volume;
synth.SpeakAsync(voiceClass.VoiceText);
}
catch(Exceptioner)
{
MessageBox.Show(er.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
///<summary>
///保存
///</summary>
///<paramname="sender"></param>
///<paramname="e"></param>
privatevoidbtnSave_Click(objectsender,EventArgse)
{
if(IsVaild())
{
synth=GetSpeechSynthesizerInstance();
VoiceClassvoiceClass=GetVoiceClass();
synth.SelectVoice(voiceClass.VoiceName);
synth.Rate=voiceClass.Rate;
synth.Volume=voiceClass.Volume;
SaveFileDialogsaveFileDialog=newSaveFileDialog();
saveFileDialog.Title="保存文档";
saveFileDialog.Filter="*.wav|*.wav|*.mp3|*.mp3";
saveFileDialog.InitialDirectory=Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
DialogResultsaveDialog=saveFileDialog.ShowDialog();
try
{
if(saveDialog==System.Windows.Forms.DialogResult.OK)
{
synth.SetOutputToWaveFile(saveFileDialog.FileName);
synth.Speak(voiceClass.VoiceText);
synth.SetOutputToNull();
System.Diagnostics.Process.Start("Explorer.exe",string.Format(@"/select,{0}",saveFileDialog.FileName));//打开wav目录并选中文件
}
}
catch(Exceptioner)
{
MessageBox.Show(er.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
}
///<summary>
///继续
///</summary>
///<paramname="sender"></param>
///<paramname="e"></param>
privatevoidbtnContinum_Click(objectsender,EventArgse)
{
synth.Resume();
}
///<summary>
///暂停
///</summary>
///<paramname="sender"></param>
///<paramname="e"></param>
privatevoidbtnStop_Click(objectsender,EventArgse)
{
synth.Pause();
}

  有个问题,不知道是什么原因,要播放的内容:欢迎致电12345客服服务系统,它把12345给我朗读成:1万2千3百4十五。这个问题还在解决中,谁知道麻烦给我留下言,谢谢。