Ejemplo n.º 1
0
 // Start is called before the first frame update
 void Start()
 {
     if (!recognizer.IsRunning)
     {
         recognizer.Start();
     }
 }
Ejemplo n.º 2
0
 // === Start Method === //
 // Checks '/StreamingAssets' for 'SimpleGrammar.xml' and reads it.
 // It uses that grammar for the GrammarRecognizer with a low confidence level.
 private void Start()
 {
     gr = new GrammarRecognizer(Application.streamingAssetsPath + "/SimpleGrammar.xml", ConfidenceLevel.Low);
     gr.OnPhraseRecognized += GR_OnPhraseRecognized;
     gr.Start();
     Debug.Log("Grammar loaded and recogniser started!");
 }
    void loadGrammar()
    {
        if (string.IsNullOrEmpty(r_gramarFile))
        {
            Debug.LogErrorFormat("Grammar File hasn't been specified");
        }
        else
        {
            try
            {
                r_grammar = new GrammarRecognizer(Application.dataPath + "/StreamingAssets/" + r_gramarFile, ConfidenceLevel.Low);
            }
            catch (UnityException e)
            {
                Debug.LogErrorFormat(e.ToString());
                Debug.LogErrorFormat("The error might be because the file '" + r_gramarFile + "' doesn't exists in the StreamingAssets folder");
            }

            if (r_grammar != null)
            {
                r_grammar.OnPhraseRecognized += Grammar_OnPhraseRecognized;
                r_grammar.Start();

                r_grammarActionsDictionary = new Dictionary <string, UnityEngine.Events.UnityEvent>();
                foreach (GrammarActions ga in r_grammarActions)
                {
                    r_grammarActionsDictionary.Add(new KeyValuePair <string, UnityEngine.Events.UnityEvent>(ga.id, ga.action));
                }
            }
        }
    }
Ejemplo n.º 4
0
    // Start is called before the first frame update
    void Start()
    {
        gm = GameObject.FindObjectOfType <GameManager>();

        LettersTranslation = new Dictionary <string, char>
        {
            { "aye", 'A' },
            { "bee", 'B' },
            { "sea", 'C' },
            { "dee", 'D' }
        };

        NumbersTranslation = new Dictionary <string, int>
        {
            { "zero", 0 },
            { "one", 1 },
            { "two", 2 },
            { "three", 3 }
        };
        string path = Application.streamingAssetsPath + "/Grammars/GrammarInput.xml";

        Debug.Log(path);
        gr = new GrammarRecognizer(path);
        //gr = new GrammarRecognizer(@"C:\Users\Sahar\Documents\Projects\Unity\2D projects\Puzzle Voice Commands\Assets\Grammars\GrammarInput.xml");
        gr.OnPhraseRecognized += RecognizeSpeech;
        gr.Start();
    }
Ejemplo n.º 5
0
    public void StartGrammer()
    {
        if (PhraseRecognitionSystem.Status != SpeechSystemStatus.Stopped)
        {
            PhraseRecognitionSystem.Shutdown();
        }

        try {
            m_GrammerRecognizer = new GrammarRecognizer(Application.streamingAssetsPath + "/SRGS/AmexGrammer.xml", ConfidenceLevel.Low);
        } catch (Exception ex) {
            Debug.Log(ex.Message);
        }

        m_GrammerRecognizer.OnPhraseRecognized += ((PhraseRecognizedEventArgs args) => {
            Debug.Log("Phrase recognized..");
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("{0} ({1}){2}", args.text, args.confidence, Environment.NewLine);
            m_Recognitions.text += builder.ToString();
        });

        m_Recognitions.text = "";

        m_GrammerRecognizer.Start();

        m_Hypotheses.text  = m_GrammerRecognizer.IsRunning? "True": "False";
        m_Hypotheses.text += "\n" + m_GrammerRecognizer.GrammarFilePath;
        enableUI("StartGrammer");
    }
Ejemplo n.º 6
0
    public Vector3 savedPosition; // Position of first color to change with rotation for the last object

    private void Start()
    {   // Color objects
        actions.Add("yellow", YellowColor);
        actions.Add("green", GreenColor);
        actions.Add("blue", BlueColor);
        actions.Add("red", RedColor);
        actions.Add("orange", OrangeColor);
        actions.Add("purple", PurpleColor);
        // Game buttons
        actions.Add("start", StartGame);
        actions.Add("pause", Pause);
        actions.Add("left", RotateLeft);
        actions.Add("right", RotateRight);

        // Pause menu buttons
        actions.Add("resume", Resume);
        actions.Add("menu", Menu);
        actions.Add("quit", Quit);

        gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                                "GameGrammar.xml"),
                                   ConfidenceLevel.Low);
        Debug.Log("Grammar loaded!");
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();
        if (gr.IsRunning)
        {
            Debug.Log("Recogniser running");
        }
    }
    private void Start()
    {   // Main menu buttons
        actions.Add("play", Play);
        actions.Add("volume", Leaderboard);
        actions.Add("quit", Quit);
        actions.Add("back", Back);

        actions.Add("easy", Easy);
        actions.Add("medium", Medium);
        actions.Add("hard", Hard);

        actions.Add("off", Off);
        actions.Add("twentyFive", TwentyFive);
        actions.Add("fifty", Fifty);
        actions.Add("seventyFive", SeventyFive);
        actions.Add("oneHundred", OneHundred);


        gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                                "GameGrammar.xml"),
                                   ConfidenceLevel.Low);
        Debug.Log("Grammar loaded!");
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();
        if (gr.IsRunning)
        {
            Debug.Log("Recogniser running");
        }
    }
Ejemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        // Setup Singleton
        if (instance == null)
        {
            instance = this;
        }

        // Setup GrammarRecognizer
        grammarRecPas = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath, "PasswordGrammar.xml"), ConfidenceLevel.Low);
        Debug.Log("Grammar has Loaded!");
        grammarRecPas.OnPhraseRecognized += grammarRecPas_OnPhraseRecognized;
        grammarRecPas.Start();
        if (grammarRecPas.IsRunning)
        {
            Debug.Log("GrammerRecognizer is Running!");
        }

        // Setup GrammarRecognizer
        grammarRec = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath, "BasicGrammar.xml"), ConfidenceLevel.Low);
        Debug.Log("Password Grammar has Loaded!");
        grammarRec.OnPhraseRecognized += grammarRec_OnPhraseRecognized;
        grammarRec.Start();
        if (grammarRec.IsRunning)
        {
            Debug.Log("GrammerRecognizerPassword is Running!");
        }

        hasSaidPassword = false;
    }
 // Use this for initialization
 void Start()
 {
     // pass path of your grammar XML in the constructor
     grammerRecognizer = new GrammarRecognizer(Application.dataPath + "/StreamingAssets/SRGS/grammar.xml");
     grammerRecognizer.OnPhraseRecognized += OnGrammerRecognized;
     grammerRecognizer.Start();
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Makes sure the GrammarRecognizer isn't running, then starts it if it isn't.
 /// </summary>
 public void StartGrammarRecognizer()
 {
     if (grammarRecognizer != null && !grammarRecognizer.IsRunning)
     {
         grammarRecognizer.Start();
     }
 }
Ejemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath, "Grammer.xml"), ConfidenceLevel.Low);
     gr.OnPhraseRecognized += GR_OnPhraseRecognized;
     gr.Start();
     Debug.Log("Grammar Loaded and Recogniser Started");
 }
    // Defines actions
    // Starts grammar recogniser
    private void Start()
    {
        // Actions and defining the UI Manager
        menuControl = gameObject.GetComponent <UIManager>();
        actions.Add("run", Run);
        actions.Add("walk", Walk);
        actions.Add("left", Left);
        actions.Add("right", Right);
        actions.Add("jump", Jump);
        actions.Add("enter", Enter);
        actions.Add("pause", Pause);
        actions.Add("tutorial", Tutorial);
        actions.Add("return", Return);
        actions.Add("quit", Tutorial);
        actions.Add("replay", Replay);
        actions.Add("menu", Menu);
        actions.Add("stop", Stop);

        mario = GameObject.Find("Mario");
        gr    = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                                   "GameOptions.xml"),
                                      ConfidenceLevel.Low);
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();
    }
 void Update()
 {
     if (PauseMenu.gameIsPaused = false && !gr.IsRunning)
     {
         gr.Start();
     }
 }
Ejemplo n.º 14
0
 private void Start()
 {
     gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath, "Grammer.xml"), ConfidenceLevel.Low);
     gr.OnPhraseRecognized += GR_OnPhraseRecognized;
     gr.Start();
     Debug.Log("Grammar Loaded and Recogniser Started");
     player = GetComponent <Transform>();
     rb     = GetComponent <Rigidbody2D>();
 }
Ejemplo n.º 15
0
 void Start()
 {
     foreach (var semantic in semanticEvents)
     {
         semantics.Add(semantic.semantics, semantic.semanticEvent);
     }
     m_Recognizer = new GrammarRecognizer(Application.streamingAssetsPath + m_GrammarFile);
     m_Recognizer.OnPhraseRecognized += OnPhraseRecognized;
     m_Recognizer.Start();
 }
Ejemplo n.º 16
0
    /// <summary>
    /// on swapping to T2 of the scenario, stop current Grammar Recognizer,
    /// dispose of current resources for it (grXML), assign T2 grXML file,
    /// and start the Grammar Recognizer.
    /// </summary>
    public void initGrammarT2()
    {
        grammarRec.Stop();
        grammarRec.Dispose();
        grammarRec = new GrammarRecognizer(Application.streamingAssetsPath + "/XML/grammar_OfficeT2.xml");
        grammarRec.OnPhraseRecognized += OnGrammerRecognized;
        grammarRec.Start();

        //Debug.Log("grammar T2 started\nStreaming asset path: " + grammarRec.GrammarFilePath);
    }
Ejemplo n.º 17
0
 public void StartGrammarRecognizer()
 {
     Debug.Log("GrammarRecognizer starting");
     if (grammarRecognizer != null && !grammarRecognizer.IsRunning)
     {
         GrammarStatusText.text  = "...";
         GrammarStatusText.color = Color.green;
         EnableGrammarStatus();
         grammarRecognizer.Start();
     }
 }
Ejemplo n.º 18
0
 private void Start()
 {
     // Setup GrammarRecognizer set state to START and run coroutine SetupBattle
     grammarRec = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath, "MenuGrammar.xml"), ConfidenceLevel.Low);
     Debug.Log("Grammer has loaded!");
     grammarRec.OnPhraseRecognized += grammarRec_OnPhraseRecognized;
     grammarRec.Start();
     if (grammarRec.IsRunning)
     {
         Debug.Log("GrammerRecognizer is Running!");
     }
 }
    // Awake listens for grammar that matches the xml
    private void Awake()
    {
        // Set initial spoken word to null
        spokenWord = "";

        gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                                "Grammer.xml"),
                                   ConfidenceLevel.Low);
        Debug.Log("Grammar loaded!"); // Test
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();                   // Starts the recogniser
    }
 // Initialise.
 void Start()
 {
     spokenPhraseText.text = "Spoken Phrase:";
     gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath, "MainMenuGrammar.xml"), ConfidenceLevel.Low);
     Debug.Log("Grammar loaded!");
     gr.OnPhraseRecognized += GR_OnPhraseRecognized;
     gr.Start();
     if (gr.IsRunning)
     {
         Debug.Log("Main menu grammar recogniser is running.");
     }
 }
Ejemplo n.º 21
0
 // Start is called before the first frame update
 void Start()
 {
     gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                             "Grammar.xml"),
                                ConfidenceLevel.Low);
     Debug.Log("Grammar loaded!");
     gr.OnPhraseRecognized += GR_OnPhraseRecognized;
     gr.Start();
     if (gr.IsRunning)
     {
         Debug.Log("Recogniser running");
     }
 }
Ejemplo n.º 22
0
    // Use this for initialization
    void Start()
    {
        //audio variables
        //Debug.Log(path);
        grammar_Recognizer = new GrammarRecognizer(path);
        grammar_Recognizer.OnPhraseRecognized += OnKeywordsRecognized;
        grammar_Recognizer.Start();

        myRigidBody     = GetComponent <Rigidbody2D> ();
        myCollider      = GetComponent <Collider2D> ();
        myAnimator      = GetComponent <Animator> ();
        theScoreManager = FindObjectOfType <ScoreManager> ();
    }
Ejemplo n.º 23
0
 private void Start()
 {
     sc = GameObject.Find("SceneController").GetComponent <SceneController>();
     gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                             "MenuGrammar.xml"),
                                ConfidenceLevel.Low);
     Debug.Log("Grammar loaded!");
     gr.OnPhraseRecognized += GR_OnPhraseRecognized;
     gr.Start();
     if (gr.IsRunning)
     {
         Debug.Log("Recogniser running");
     }
 }
Ejemplo n.º 24
0
 // Use this for initialization
 void Start()
 {
     //Used for SRGS Grammar
     if (grammarRecognizer == null)
     {
         grammarRecognizer = new GrammarRecognizer(Application.streamingAssetsPath + "/SRGS/myGrammar.xml");
         grammarRecognizer.OnPhraseRecognized += (args) =>
         {
             SemanticMeaning[] meanings = args.semanticMeanings;
             // do something;
         };
         grammarRecognizer.Start();
     }
 }
Ejemplo n.º 25
0
    void Start()
    {
        xRay   = itemCanvas.transform.Find("X-Ray").gameObject;
        test   = itemCanvas.transform.Find("Test").gameObject;
        result = itemCanvas.transform.Find("Result").gameObject;

        xRay.SetActive(false);
        test.SetActive(false);
        result.SetActive(false);

        grammarRecognizer = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath, "grammar.xml"), ConfidenceLevel.Medium);
        grammarRecognizer.OnPhraseRecognized += grammarRecognizer_OnPhraseRecognized;
        grammarRecognizer.Start();
    }
Ejemplo n.º 26
0
    private void Start()
    {
        // Loads in the grammar recognizer at game start.
        gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath, "GameGrammar.xml"), ConfidenceLevel.Low);
        Debug.Log("Grammar loaded!");
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();
        if (gr.IsRunning)
        {
            Debug.Log("Recogniser running");
        }

        Time.timeScale = 0f;
    }
    private void Start()
    {
        actions.Add("play", Play);

        gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                                "GameGrammar.xml"),
                                   ConfidenceLevel.High);
        Debug.Log("Grammar loaded!");
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();
        if (gr.IsRunning)
        {
            Debug.Log("Recogniser running");
        }
    }
Ejemplo n.º 28
0
    private void Awake()
    {
        // starts the recogizer to listen out to rules from the MainMenuGrammar XML file
        gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                                "MainMenuGrammar.xml"),
                                   ConfidenceLevel.Low);
        Debug.Log("Grammar loaded!");
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();
        if (gr.IsRunning)
        {
            Debug.Log("Recogniser running");
        }

        phrase = "";
    }
    private void Start()
    {
        gr = new GrammarRecognizer(Application.streamingAssetsPath + "/SimpleGrammar.xml", ConfidenceLevel.Medium);
        Debug.Log("Grammar loaded!");
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();

        if (gr.IsRunning)
        {
            Debug.Log("Grammar is running!");
        }
        else
        {
            Debug.Log("Grammar is not running!");
        }
    }
Ejemplo n.º 30
0
    // Defines the grammar path and starts the grammar recogniser
    // Creates actions
    private void Start()
    {
        menuControl = gameObject.GetComponent <UIManager>();

        actions.Add("ok", Ok);
        actions.Add("begin", Begin);
        actions.Add("tutorial", Tutorial);
        actions.Add("quit", Quit);
        actions.Add("return", Tutorial);

        gr = new GrammarRecognizer(Path.Combine(Application.streamingAssetsPath,
                                                "MenuOptions.xml"),
                                   ConfidenceLevel.Low);
        gr.OnPhraseRecognized += GR_OnPhraseRecognized;
        gr.Start();
    }