C# ContinuousRecognitionSession.StartAsync()返回“访问被拒绝”
我尝试使用BackgroundApplication在Raspberry PI 3中实现语音识别器。我正在使用UWP中的SpeechRecognitor类 调用此函数ContinuousRecognitionSession.StartAsync时出现此错误“访问被拒绝” 有什么问题 代码是:C# ContinuousRecognitionSession.StartAsync()返回“访问被拒绝”,c#,uwp,raspberry-pi3,windowsiot,background-application,C#,Uwp,Raspberry Pi3,Windowsiot,Background Application,我尝试使用BackgroundApplication在Raspberry PI 3中实现语音识别器。我正在使用UWP中的SpeechRecognitor类 调用此函数ContinuousRecognitionSession.StartAsync时出现此错误“访问被拒绝” 有什么问题 代码是: class Speech { private static SpeechRecognizer speechRecognizer; public async static void Initi
class Speech
{
private static SpeechRecognizer speechRecognizer;
public async static void Initialize()
{
speechRecognizer = new SpeechRecognizer();
speechRecognizer.Constraints.Add(new SpeechRecognitionListConstraint(new List<String>() { "Hello" }, "Hello"));
SpeechRecognitionCompilationResult compilationResult = await speechRecognizer.CompileConstraintsAsync();
speechRecognizer.ContinuousRecognitionSession.ResultGenerated += ContinuousRecognitionSession_ResultGenerated;
}
private static void ContinuousRecognitionSession_ResultGenerated(SpeechContinuousRecognitionSession sender, SpeechContinuousRecognitionResultGeneratedEventArgs args)
{
throw new NotImplementedException();
}
public static async Task<bool> StartRecognition()
{
try
{
await speechRecognizer.ContinuousRecognitionSession.StartAsync();
}
catch (Exception eException)
{
return false;
}
return true;
}
}
正如@Tóth Tibor指出的,您需要在Package.appxmanifest中声明麦克风功能,如下所示:
<Capabilities>
<DeviceCapability Name="microphone" />
</Capabilities>
有关更多信息,请参考。您是否在package.appxmanifest中添加了麦克风功能?
<Capabilities>
<DeviceCapability Name="microphone" />
</Capabilities>