0
我有一個使用mvc的服務,在這種情況下,我有一個控制器正在實現apicontroler,我從另一個項目調用一個帖子並傳遞給它一個流。然後我得到字符串並在其上工作。 這個方法運行並返回正確的值,但是我沒有得到任何我稱之爲的東西。它看起來像在工作,但沒有任何反應。語音識別掛在ApiController
這是代碼。
result = new List<string>();
Stream stream = new MemoryStream();
Task loadingStream = (Request.Content as StreamContent).CopyToAsync(stream);
loadingStream.Wait();
stream.Position = 0;
SpeechRecognitionEngine _appRecognizer = new SpeechRecognitionEngine(new CultureInfo("en-US"));
_appRecognizer.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(SpeechRecognized);
_appRecognizer.SetInputToWaveStream(stream);
_appRecognizer.LoadGrammar(new Grammar(@"C:\Users\Thomas\Desktop\grammar1.srgs"));
RecognitionResult recognitionResult = _appRecognizer.Recognize();
_appRecognizer.SpeechRecognized -= SpeechRecognized;
return recognitionResult != null ? recognitionResult.Text : null;