2017-03-17 33 views
0

BackgroundApplicationを使用してRaspberry PI 3で音声リコンライザーを実装しようとしています。私はUWPのSpeechRecognizerクラスを使用しています。ContinuousRecognitionSession.StartAsync()は「アクセスが拒否されました」を返します

私は、このエラーはContinuousRecognitionSession.StartAsync()

この関数を呼び出すときに問題は何ですか?「アクセスが拒否されました」GET

コードは次のとおりです。

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; 
    } 
} 

public sealed class StartupTask : IBackgroundTask 
{ 
    BackgroundTaskDeferral _deferral; 

    public async void Run(IBackgroundTaskInstance taskInstance) 
    { 
     _deferral = taskInstance.GetDeferral(); 
     Speech.Initialize(); 
     await Speech.StartRecognition(); 
    } 
} 
+0

microsoft機能をpackage.appxmanifestに追加しましたか? –

答えて

1

トスティボーが指摘@として、あなたはこのようPackage.appxmanifestにマイク機能を宣言する必要がありますについては

<Capabilities> 
    <DeviceCapability Name="microphone" /> 
    </Capabilities> 

詳細については"Set the Microphone device capability""Enable device capabilities"を参照してください。

関連する問題