資源簡介
研究了一下C#的文本語音朗讀,寫了一個小demo,在32位win7下可以運行朗讀,還可以將朗讀保存WAV,,,大家可以參考參考

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?DotNetSpeech;
namespace?SpeechApp
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????///?
????????///?朗讀
????????///?
????????///?
????????///?
????????private?void?ButtonSynthesis_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????DotNetSpeech.SpeechVoiceSpeakFlags?SSF?=?DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
????????????????DotNetSpeech.SpVoice?vo?=?new?SpVoiceClass();
????????????????vo.Speak(this.textBox1.Text?SSF);
????????????????
????????????}
????????????catch?(System.Exception?ec)
????????????{
????????????????MessageBox.Show(ec.ToString()?“SpeechApp“?MessageBoxButtons.OK?System.Windows.Forms.MessageBoxIcon.Error);
????????????}
????????}
????????///?
????????///?生成聲音文件
????????///?
????????///?
????????///?
????????private?void?ButtonTTStoWave_Click(object?sender?EventArgs?e)
????????{
????????????try
????????????{
????????????????DotNetSpeech.SpeechVoiceSpeakFlags?SSF?=?DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync;
????????????????DotNetSpeech.SpVoice?vo?=?new?SpVoiceClass();
????????????????System.Windows.Forms.SaveFileDialog?SFD?=?new?System.Windows.Forms.SaveFileDialog();
????????????????SFD.Filter?=?“All?files?(*.*)|*.*|wav?files?(*.wav)|*.wav“;
????????????????SFD.title?=?“Save?to?a?wav?file“;
????????????????SFD.FilterIndex?=?2;
????????????????SFD.RestoreDirectory?=?true;
????????????????if?(SFD.ShowDialog()?==?System.Windows.Forms.DialogResult.OK)
????????????????{
????????????????????DotNetSpeech.SpeechStreamFileMode?SSFM?=?DotNetSpeech.SpeechStreamFileMode.SSFMCreateForWrite;
????????????????????DotNetSpeech.SpFileStream?SFS?=?new?DotNetSpeech.SpFileStreamClass();
????????????????????SFS.Open(SFD.FileName?SSFM?false);
????????????????????vo.AudioOutputStream?=?SFS;
????????????????????vo.Speak(this.textBox1.Text?SSF);
????????????????????vo.WaitUntilDone(System.Threading.Timeout.Infinite);
????????????????????SFS.Close();
????????????????}
????????????}
????????????catch?(System.Exception?ec)
????????????{
????????????????MessageBox.Show(ec.ToString()?“SpeechApp“?MessageBoxButtons.OK?System.Windows.Forms.MessageBoxIcon.Error);
????????????}
????????}
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????163840??2017-02-22?14:32??SpeechApp\SpeechApp\bin\Debug\DotNetSpeech.dll
?????文件???????9728??2017-02-22?16:05??SpeechApp\SpeechApp\bin\Debug\SpeechApp.exe
?????文件??????26112??2017-02-22?16:05??SpeechApp\SpeechApp\bin\Debug\SpeechApp.pdb
?????文件??????11608??2017-02-22?16:08??SpeechApp\SpeechApp\bin\Debug\SpeechApp.vshost.exe
?????文件????????490??2010-03-17?22:39??SpeechApp\SpeechApp\bin\Debug\SpeechApp.vshost.exe.manifest
?????文件???????2701??2017-02-22?16:05??SpeechApp\SpeechApp\Form1.cs
?????文件???????3463??2017-02-22?16:05??SpeechApp\SpeechApp\Form1.Designer.cs
?????文件???????5817??2017-02-22?16:05??SpeechApp\SpeechApp\Form1.resx
?????文件???????6278??2017-02-22?16:05??SpeechApp\SpeechApp\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????566??2017-02-22?16:05??SpeechApp\SpeechApp\obj\x86\Debug\GenerateResource-ResGen.read.1.tlog
?????文件????????922??2017-02-22?16:05??SpeechApp\SpeechApp\obj\x86\Debug\GenerateResource-ResGen.write.1.tlog
?????文件???????2714??2017-02-22?16:01??SpeechApp\SpeechApp\obj\x86\Debug\ResolveAssemblyReference.cache
?????文件???????1083??2017-02-22?16:08??SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.csproj.FileListAbsolute.txt
?????文件???????9728??2017-02-22?16:05??SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.exe
?????文件????????180??2017-02-22?16:05??SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.Form1.resources
?????文件??????26112??2017-02-22?16:05??SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.pdb
?????文件????????180??2017-02-22?16:01??SpeechApp\SpeechApp\obj\x86\Debug\SpeechApp.Properties.Resources.resources
?????文件????????490??2017-02-22?15:56??SpeechApp\SpeechApp\Program.cs
?????文件???????1370??2017-02-22?15:56??SpeechApp\SpeechApp\Properties\AssemblyInfo.cs
?????文件???????2869??2017-02-22?15:56??SpeechApp\SpeechApp\Properties\Resources.Designer.cs
?????文件???????5612??2017-02-22?15:56??SpeechApp\SpeechApp\Properties\Resources.resx
?????文件???????1095??2017-02-22?15:56??SpeechApp\SpeechApp\Properties\Settings.Designer.cs
?????文件????????249??2017-02-22?15:56??SpeechApp\SpeechApp\Properties\Settings.settings
?????文件???????3816??2017-02-22?16:01??SpeechApp\SpeechApp\SpeechApp.csproj
?????文件????????869??2017-02-22?15:56??SpeechApp\SpeechApp.sln
????..A..H.?????19456??2017-02-22?16:09??SpeechApp\SpeechApp.suo
?????目錄??????????0??2017-02-22?15:56??SpeechApp\SpeechApp\obj\x86\Debug\TempPE
?????目錄??????????0??2017-02-22?16:05??SpeechApp\SpeechApp\obj\x86\Debug
?????目錄??????????0??2017-02-22?16:01??SpeechApp\SpeechApp\bin\Debug
?????目錄??????????0??2017-02-22?15:56??SpeechApp\SpeechApp\obj\x86
............此處省略8個文件信息
評論
共有 條評論