Search Unity

Question GrammarRecognizer Problems within Unity, nothing is recognized, need Help please

Discussion in 'AR' started by powerschaf, May 18, 2021.

  1. powerschaf

    powerschaf

    Joined:
    Apr 7, 2020
    Posts:
    3
    I am programming an App for my bachelor thesis for HoloLens2 and i am familiar with C# / Unity.
    I tried the whole day to get this to work.

    Unity Version is 2020.3.6f1
    Visual Studio 2019 (version 16.9.4)

    My Code:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Windows.Speech;
    3.  
    4. public class test : MonoBehaviour
    5. {
    6.     private GrammarRecognizer m_recognizer;
    7.     public GrammarRecognizer Recognizer { get => m_recognizer; set => m_recognizer = value; }
    8.  
    9.     void Start()
    10.     {
    11.         Recognizer = new GrammarRecognizer(Application.streamingAssetsPath + "/SRGS/test.xml");
    12.         Recognizer.OnPhraseRecognized += Recognizer_OnPhraseRecognized;
    13.         Recognizer.Start();
    14.     }
    15.  
    16.     private void Recognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
    17.     {
    18.         Debug.Log("I recognized something");
    19.     }
    20.  
    21.     // Update is called once per frame
    22.     void Update()
    23.     {
    24.         if(Recognizer.IsRunning)
    25.         {
    26.             Debug.Log("Running");
    27.         }
    28.     }
    29. }
    And the XML File:

    <grammar version="1.0" xml:lang="en-US" root="rootRule"
    xmlns="http://www.w3.org/2001/06/grammar">

    <rule id="rootRule">
    <item>play</item>
    </rule>

    </grammar>


    I dont understand why this is not working. I implemented the DictationHandler without any problems and everything is recognized. The DictationHandler is not running while i test the GrammarRecognizer.
     
  2. romlel

    romlel

    Joined:
    Aug 28, 2013
    Posts:
    3
    Hello

    Could you find a solution ?
    I have the same problem. I suspect the gramma file path is problematic on Hololens, and tried some alternatives, but no error, no exception... and no recognition !

    Did you find the source of the problem ?
    Thanks a lot :)