speech recognition - UWP SpeechRecognition exception with file grammar -
i'm tring add custom srgr grammar speechrecognition in w10 uwp app. i've w10 creators update.
app goes in exception on "recognizer.recognizeasync" without code , message when add grammar file below
private async void button_click(object sender, routedeventargs e) { try { using (speechrecognizer recognizer = new speechrecognizer()) { var webgrammar = new speechrecognitiontopicconstraint(speechrecognitionscenario.websearch, "websearch", "web"); //recognizer.constraints.add(webgrammar); storagefile grammarfile = await storagefile.getfilefromapplicationuriasync( new uri("ms-appx:///grammar.xml")); recognizer.constraints.add(new speechrecognitiongrammarfileconstraint(grammarfile)); speechrecognitioncompilationresult compilationresult = await recognizer.compileconstraintsasync(); speechrecognitionresult result = await recognizer.recognizeasync(); string recognizedtext = "non ho capito"; if (result.status == speechrecognitionresultstatus.success) { recognizedtext = result.text; } await dispatcher.runasync(windows.ui.core.coredispatcherpriority.normal, () => { uiuserinput.text = recognizedtext; }); } } catch (exception ex) { system.diagnostics.debug.writeline(ex.message); } }
ideas?
Comments
Post a Comment