0

請當它達到e.SetInputToWaveStream(stream);它拋出錯誤System.FormatException: Wave file not validSystem.FormatException:Wave文件無效

什麼是這裏的問題看看下面的代碼片段

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); 

回答

0

發現此問題。在設置爲輸入之前需要呼叫stream.Position = 0