效果演示:
试听效果
前段时间是用C#做了一个简单的文本朗读系统,最近需要把文字转换成声音文件,所以有对原系统进行了扩充,其实代码也挺简单的。这里给出将文本转存问声音的C#代码:
SpeechVoiceSpeakFlags spFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
SpVoice sp = new SpVoice();
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav";
sfd.Title = "Save to a wave file";
sfd.FilterIndex = 2;
sfd.RestoreDirectory = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
SpFileStream spFileStream = new SpFileStream();
spFileStream.Open(sfd.FileName, SpeechStreamFileMode.SSFMCreateForWrite, false);
sp.AudioOutputStream = spFileStream;
sp.Speak(rtbContent.Text, spFlags);
sp.WaitUntilDone(System.Threading.Timeout.Infinite);
spFileStream.Close();
}
我用vs2008打包成安装包了,需要的可以从这下载安装:http://u.115.com/file/f4a190f10b
- from the5fire.com
----EOF-----
微信公众号:Python程序员杂谈
微信公众号:Python程序员杂谈