我正在开发阅读一些文本并说出文本的Windows Phone 7应用程序。SoundEffect在从SpeechLib分配缓冲区时产生错误
micsoroft库 - interop.speechlib.dll将我的文本转换为缓冲区(字节数组)。和SoundEffect Windows Phone 7的插件说话。
这一切都工作正常,但有时它通过提高波纹管无差错
缓冲区无效造成的问题。确保缓冲区长度为非零和满足音频格式
代码话语块对齐要求是按如下:
SoundEffect se = new SoundEffect(buffer, 15000, AudioChannels.Stereo);
FrameworkDispatcher.Update();
se.Play();
请给我建议,我哪里做错了。
编辑 从一些测试我认为问题的根本原因是缓冲区的产生。以下是从文本生成缓冲区的代码。
using (MemoryStream ms = new MemoryStream())
{
SpeechLib.SpVoice oVoice = new SpeechLib.SpVoice();
SpeechLib.SpFileStream cpFileStream = new SpeechLib.SpFileStream();
cpFileStream.Open(filename, SpeechLib.SpeechStreamFileMode.SSFMCreateForWrite, false);
oVoice.AudioOutputStream = cpFileStream;
oVoice.Speak(value, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault);
oVoice = null;
cpFileStream.Close();
cpFileStream = null;
byte[] ImageData=File.ReadAllBytes(filename);
return ImageData;
}
感谢, 纳雷什Goradara
感谢奥利弗它们之间的区别,我发现的根本原因这一。它不在SoundEffect中,而是在缓冲区生成。我已经添加了我的代码,请看看并建议。 – 2011-05-11 05:32:19