[英]SpeechSynthesizer in C# creates wav that has 22kHz… needs to be 16kHz
My C# application needs to covert text to wav file and inject it into a Skype call. 我的C#应用程序需要将文本转换为wav文件并将其注入Skype调用。 The code that creates the wav file is below.
创建wav文件的代码如下所示。 The problem is that the file has 22kHz sample rate and Skype accepts only 16kHz.
问题是文件的采样率为22kHz,Skype只接受16kHz。
Is there any way to adjust this setting? 有没有办法调整此设置?
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()
has an overload that accepts a SpeechAudioFormatInfo
parameter, which can be used to set the sample rate. SetOutputToWaveFile()
有一个接受SpeechAudioFormatInfo
参数的重载,该参数可用于设置采样率。
Don't see one for
since you're writing to a file anyway, that should work. SetOutputToWaveStream()
, oddly, but
奇怪的是,没有为
因为你无论如何都要写一个文件,这应该有效。 SetOutputToWaveStream()
看到一个,但是
Edit: 编辑:
As @Hans points out, the correct overload is SetOutputToAudioStream()
to write to a stream. 正如@Hans指出的那样,正确的重载是
SetOutputToAudioStream()
来写入流。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.