安装 Windows IoT (10.0.10586) 和 Visual Studio 2015 Update 1 后,当我在 Raspberry Pi 2(使用 Windows IoT 10.0.10586)上的通用应用程序中使用 SpeechRecognizer 时,出现 COM-Exception。
如果我在 Windows 10 上运行 SpeechRecognizer UWP 应用程序,它可以正常工作,但 COM 异常仅出现在 Windows IoT (10.0.10586) 中。对于旧版本的 Windows IoT 和没有 Update 1 的 Visual Studio 2015,它也可以工作。
有人能解决这个问题吗?
var speechRecognizer = new SpeechRecognizer();
var constraint = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.Dictation, "dictation");
speechRecognizer.Constraints.Add(constraint);
await speechRecognizer.CompileConstraintsAsync();
//This line throw exception:
//Exception thrown: 'System.Runtime.InteropServices.COMException' in App.exe
//WinRT information: Class not registered
//Operation not supported.Unknown error: 0x80070057.
var result = await speechRecognizer.RecognizeWithUIAsync();
要获取示例工作,请在 Package.appxmainifest 中启用以下功能:
互联网(客户端)和麦克风
编辑
就像 Eric Brown 所说的,RecognizeWithUIAsync 似乎不适用于 Windows IoT(我没记错,似乎我从未使用过 RecognizeWithUIAsync,但我知道 SpeechRecognizer 过去可以工作)。
但是 RecognizeAsync 也不适用于我。没有抛出异常,但 RecognizeAsync 不等待语音,它直接返回一个 SpeechRecognitionResult 对象,其中属性 Confidence 为 Rejected,Status 为 Success,但语音 Text 始终为空字符串。它适用于 Windows 10,但不适用于 Windows IoT。
有谁知道为什么没有检测到语音/说出的单词不会被返回?
var speechRecognizer = new SpeechRecognizer();
var constraint = new SpeechRecognitionTopicConstraint(SpeechRecognitionScenario.Dictation, "dictation");
speechRecognizer.Constraints.Add(constraint);
await speechRecognizer.CompileConstraintsAsync();
while (true)
{
var result = await speechRecognizer.RecognizeAsync();
Debug.WriteLine(!string.IsNullOrEmpty(result.Text) ? result.Text : "No speech in result.");
}
要获取示例工作,请在 Package.appxmainifest 中启用以下功能:
互联网(客户端)和麦克风
最佳答案
RecognizeWithUIAsync
未在 Windows IoT 中实现(因为没有 UI)。您可以使用 RecognizeAsync
就可以了。
关于visual-studio-2015 - SpeechRecognizer 无法工作,COMException : Class not registered/UWP App Windows IoT (10. 0.10586) 和 Visual Studio 2015 Update 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34399726/