下载安装 Speech SDK 5.1
下载地址: http://www.microsoft.com/en-us/download/details.aspx?id=10121
详细的看这篇 https://www.cnblogs.com/hailexuexi/p/17588586.html
C#示例
直接保存到wav文件 并存为 8KHZ 16比特 语音格式
private void btnSave_Click(object sender, EventArgs e) { try { SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpVoice Voice = new SpVoice(); string strFileName = "TTS/" + txtSpeakText.Text+".wav";//工程目录下以播放的内容为文件名 SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite; SpFileStream SpFileStream = new SpFileStream(); SpFileStream.Format.Type = SpeechAudioFormatType.SAFT8kHz16BitMono; //8KHZ 16比特 语音格式 //SpFileStream.Format.Type = SpeechAudioFormatType.SAFT11kHz16BitMono; //SpFileStream.Open("c:\\tts.wav", SpeechStreamFileMode.SSFMCreateForWrite, false); SpFileStream.Open(strFileName, SpFileMode, false); Voice.AudioOutputStream = SpFileStream; Voice.Speak(txtSpeakText.Text, SpFlags); Voice.WaitUntilDone(Timeout.Infinite);//Timeout.Infinite 线程超时常量 SpFileStream.Close();//关闭 } catch (Exception error) { MessageBox.Show("Speak error", "SimpleTTS " + error.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
这里有很多 音频格式
SpFileStream.Format.Type = SpeechAudioFormatType.SAFT8kHz16BitMono; //8KHZ 16比特 语音格式
十分感谢 hhmmdd 的分享
微软中文TTS 5.1引擎不能把文字转换成CCITT Alaw的wave文件格式
https://bbs.csdn.net/topics/70226414?list=76128
标签:5.1,比特,SpFileStream,16,Voice,8KHZ From: https://www.cnblogs.com/hailexuexi/p/17588608.html