【发布时间】:2018-10-11 16:48:09
【问题描述】:
我在使用 SpeechRecognizer 时遇到了 System.Runtime.InteropServices.COMException (0x80070490)。
我在网上看到这个错误可能是由于未启用功能或清单已损坏。
我启用了 Internet(客户端)和麦克风,我还尝试了一个干净的清单文件,但它导致相同的错误消息。
有人知道我做错了什么吗?这是一个 UWP 应用,我使用的是 Windows 10 Build 1709。
我的代码:
using System;
using System.Diagnostics;
using Windows.Media.SpeechRecognition;
namespace SpeechRecognitionRPi
{
class SpeechHandling
{
public async void StartRecognition()
{
// Create an instance of SpeechRecognizer.
var speechRecognizer = new SpeechRecognizer();
// Compile the dictation grammar by default.
await speechRecognizer.CompileConstraintsAsync();
// Start recognition.
SpeechRecognitionResult speechRecognitionResult = await speechRecognizer.RecognizeWithUIAsync();
// Do something with the recognition result.
var messageDialog = new Windows.UI.Popups.MessageDialog(speechRecognitionResult.Text, "Text spoken");
await messageDialog.ShowAsync();
}
}
}
【问题讨论】:
标签: c# uwp win-universal-app speech-recognition