System.FormatException:Wave文件无效

时间:2013-05-28 18:54:32

标签: c# .net visual-studio-2010 speech-recognition formatexception

请查看以下代码段

using System.IO;



MemoryStream stream = new MemoryStream();


SpeechSynthesizer s = new SpeechSynthesizer();
s.setOutputToWaveStream(stream);
s.Speak("hello world");


SpeechRecognitionEngine e = new SpeechRecognitionEngine(new System.Globalization.CuntureInfo("en-US");


//Set grammar code goes here

e.SetInputToWaveStream(stream);

当它到达e.SetInputToWaveStream(stream);时会抛出错误System.FormatException: Wave file not valid

这是什么问题?

1 个答案:

答案 0 :(得分:0)

发现了这个问题。在将其设置为输入

之前需要致电stream.Position = 0