Speech Recognizer delete elements

Updated on June 12, 2018 in Unity
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on June 12, 2018

I was wondering if it was possible to delete the keywords in the Speech recognizer?

What I am trying to do is load keywords on Awake. Then when i want to open programs I run “program executables” and this restarts and deletes the keys in the recognizer and then run the Awake functions again which will then have ProgramAccess and add those keyswords.

The problem I am having is that the elements are not being deleted, I thought .dispose would solve that however it does not and I can’t seem to find much information about Speech Recognition

After I run my “program executables” code I am getting an error saying

‘An element with the same key already exist in the dictionary’.

 

 
    void Awake()
    {
        keywords.Add("run program executables", () =>
        {
            programAccess = true;
            restartRecognizer();
        });
        if ( programAccess == true)
        {
            Debug.Log("running program executables");
            keywords.Add("open Microsoft Word", () =>
            {
                openMicrosoftWord();
                Debug.Log("KeywordAdded");
            });
        }
    void retstartRecognizer()
    {
        keywordRecognizer.Stop();
        keywordRecognizer.Dispose();
        Debug.Log("Disposed");
        Awake();
    }

Thanks in advance to anyone that can help

 

 

  • Liked by
Reply
0 on June 12, 2018

For anyone interested I found a solution.

So it turns out that I didn’t need to clear the recognizer. I forgot I created a dictionary to hold the keywords and that I can simple clear the dictionary.

 

  • Liked by
Reply
Cancel