我的C应用程序需要将文本转换为wav文件,并将其插入Skype呼叫。下面是创建wav文件的代码。问题是文件的采样率为22kHz,Skype只接受16kHz。
有什么方法可以调整这个设置吗?
using (System.IO.FileStream stream = System.IO.File.Create("message.wav")) { System.Speech.Synthesis.SpeechSynthesizer speechEngine = new System.Speech.Synthesis.SpeechSynthesizer(); speechEngine.SetOutputToWaveStream(stream); speechEngine.Speak(number); stream.Flush(); }
SetOutputToWaveFile() 具有接受 SpeechAudioFormatInfo 参数,可用于设置采样率。 看不到一个 SetOutputToWaveStream() 奇怪的是 既然你正在写一个文件,那就行了。
SetOutputToWaveFile()
SpeechAudioFormatInfo
SetOutputToWaveStream()
编辑:
正如@hans指出的,正确的过载是 SetOutputToAudioStream() 写入流。
SetOutputToAudioStream()