我有一个使用 mvc 的服务,在这种情况下,我有一个控制器正在实现 apicontroler,我从另一个项目调用一个帖子并将其传递给一个流。然后我得到字符串并处理它。这个方法运行并返回正确的值,但是我在调用它的地方没有得到任何东西。看起来它正在工作,但没有任何反应。
这是代码。
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;