![]() Use the DictationRecognizer to convert the user's speech to text. Types: DictationRecognizer, SpeechError, SpeechSystemStatus SemanticMeaning meanings = manticMeanings įinally, start recognizing! grammarRecognizer.Start() ![]() private void Grammar_OnPhraseRecognized(PhraseRecognizedEventArgs args) Most of the important information will be provided in the semanticMeanings array. You'll get a callback containing information specified in your SRGS grammar, which you can handle appropriately. Now register for the OnPhraseRecognized event grammarRecognizer.OnPhraseRecognized += grammarRecognizer_OnPhraseRecognized GrammarRecognizer = new GrammarRecognizer(Application.streamingDataPath + "/SRGS/myGrammar.xml") Once you have your SRGS grammar, and it is in your project in a StreamingAssets folder: /Assets/StreamingAssets/SRGS/myGrammar.xmlĬreate a GrammarRecognizer and pass it the path to your SRGS file: private GrammarRecognizer grammarRecognizer See: Create Grammars Using SRGS XML for file format information. This can be useful if your app has more than just a few keywords, if you want to recognize more complex phrases, or if you want to easily turn on and off sets of commands. The GrammarRecognizer is used if you're specifying your recognition grammar using SRGS. Types: GrammarRecognizer, PhraseRecognizedEventArgs, SpeechError, SpeechSystemStatus If (keywords.TryGetValue(args.text, out keywordAction))įinally, start recognizing! keywordRecognizer.Start() if the keyword recognized is in our dictionary, call that Action. ![]() Now register for the OnPhraseRecognized event keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized Īn example handler is: private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args) action to be performed when this keyword is spokenĬreate the keyword recognizer and tell it what we want to recognize: keywordRecognizer = new KeywordRecognizer(()) We're adding the "activate" keyword in this example: //Create keywords for keyword recognizer Now add a keyword to the dictionary, for example in of a Start() method. Then let's add a few fields to your class to store the recognizer and keyword->action dictionary: KeywordRecognizer keywordRecognizer We'll need a few using statements to save some keystrokes: using ![]() Types: KeywordRecognizer, PhraseRecognizedEventArgs, SpeechError, SpeechSystemStatus Handle the OnPhraseRecognized event and take action corresponding to the phrase recognized.Specify which phrases to listen for using a KeywordRecognizer or GrammarRecognizer.To enable your app to listen for specific phrases spoken by the user then take some action, you need to: You'll be asked to do this on device startup, but if you accidentally clicked "no" you can change the permissions in the device settings.Grant permissions to the app for microphone access on your HoloLens device.In the Publishing Settings > Capabilities section, check the Microphone capability.In the Unity Editor, navigate to Edit > Project Settings > Player.The Microphone capability must be declared for an app to use Voice input. If a GrammarRecognizer or KeywordRecognizer is active, a DictationRecognizer can't be active and vice versa. Dictation and phrase recognition can't be handled at the same time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |