private void CreateWAVFile(string text) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "所有文件 (*.*)|*.*|WAV 格式文件 (*.wav)|*.wav"; sfd.Title = "保存到 wave 文件"; sfd.FilterIndex = 2; sfd.RestoreDirectory = true; if (sfd.ShowDialog() == DialogResult.OK) { SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite; SpFileStream SpFileStream = new SpFileStream(); SpFileStream.Open(sfd.FileName, SpFileMode, false); speech.AudioOutputStream = SpFileStream; speech.Rate = -1; speech.Volume = volume; speech.Speak(text, SpeechVoiceSpeakFlags.SVSFlagsAsync); speech.WaitUntilDone(Timeout.Infinite); SpFileStream.Close(); } }
|
请发表评论