コード例 #1
0
    // Use this for initialization
    void Start()
    {
        keywords.Add("Reset world", () =>
        {
            // Call the OnReset method on every descendant object.
            this.BroadcastMessage("OnReset");
        });

        keywords.Add("Drop", () =>
        {
            var focusObject = GazeGestureManager.Instance.FocusedObject;
            if (focusObject != null)
            {
                // Call the OnDrop method on just the focused object.
                focusObject.SendMessage("OnDrop");
            }
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #2
0
    void Start()
    {
        //Create keywords for keyword recognizer
        keywords.Add("start", () =>
        {
            // action to be performed when this keyword is spoken
            TriggerDialogue();
        });

        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;

        keywordRecognizer.Start();
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("Speech Recognition started");
        cameraObject = Camera.main;
        keywords.Add("Snap", () =>
        {
            Debug.Log("keyword added");
            cameraObject.GetComponent <CapturePhoto>().SendMessage("Capture");
        });
        keywords.Add("WEKIT", () =>
        {
            Debug.Log("keyword added");
            cameraObject.GetComponent <CapturePhoto>().SendMessage("Capture");
        });

        keywords.Add("Next", () =>
        {
            Debug.Log("keyword added");
            //GameObject.FindGameObjectWithTag("DisplayManual").SendMessage("AssignNext");
            GameObject.FindGameObjectWithTag("Bridge").SendMessage("AssignNext");
        });

        //keywords.Add("Previous", () =>
        //{
        //    Debug.Log("keyword added");
        //    GameObject.FindGameObjectWithTag("Bridge").SendMessage("AssignPrevious");
        //    //GameObject.FindGameObjectWithTag("DisplayManual").SendMessage("AssignPrevious");

        //});

        keywords.Add("now", () =>
        {
            Debug.Log("keyword added");
            //GameObject.FindGameObjectWithTag("LegoModel").SendMessage("ExpandModel");
            GameObject.FindGameObjectWithTag("Bridge").SendMessage("ExpandModel");
        });

        keywords.Add("go", () =>
        {
            Debug.Log("keyword added");
            GameObject.FindGameObjectWithTag("LegoModel").SendMessage("ExpandModel");
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #4
0
        /// <inheritdoc />
        public override void Disable()
        {
            if (keywordRecognizer != null)
            {
                StopRecognition();
                keywordRecognizer.OnPhraseRecognized -= KeywordRecognizer_OnPhraseRecognized;

                keywordRecognizer.Dispose();
            }

            keywordRecognizer = null;

            base.Disable();
        }
コード例 #5
0
ファイル: SpeechManager.cs プロジェクト: Thanaell/CP-ARRoW
    // Use this for initialization
    void Start()
    {
        //Commande vocale "Lock" qui va attacher l'objet avec un Spatial Anchor
        keywords.Add("Lock", () =>
        {
            var focusObject = GazeInteractionManager.Instance.FocusedObject;
            if (focusObject != null)
            {
                WorldAnchorManager.Instance.AttachAnchor(focusObject);
            }
        });

        //Commande vocale "Unlock" qui va détacher l'objet en lui enlevant son Spatial Anchor
        keywords.Add("Unlock", () =>
        {
            var focusObject = GazeInteractionManager.Instance.FocusedObject;
            if (focusObject != null)
            {
                WorldAnchorManager.Instance.RemoveAnchor(focusObject);
            }
        });

        //Commande vocale "Move" qui va déclencher la méthode "OnMove" de l'objet regardé
        keywords.Add("Move", () =>
        {
            var focusObject = GazeInteractionManager.Instance.FocusedObject;
            if (focusObject != null)
            {
                focusObject.SendMessage("OnMove", SendMessageOptions.DontRequireReceiver);
            }
        });

        //Commande vocale "Stop" qui va déclencher la méthode "OnStop" de l'objet regardé
        keywords.Add("Stop", () =>
        {
            var focusObject = GazeInteractionManager.Instance.FocusedObject;
            if (focusObject != null)
            {
                focusObject.SendMessage("OnStop", SendMessageOptions.DontRequireReceiver);
            }
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #6
0
    void Start()
    {
        audioJarvis     = this.GetComponents <AudioSource>()[0];
        audioSome       = this.GetComponents <AudioSource>()[1];
        audioMission    = this.GetComponents <AudioSource>()[4];
        audioExit       = this.GetComponents <AudioSource>()[3];
        audioThanks     = this.GetComponents <AudioSource>()[2];
        audioHyperspeed = this.GetComponents <AudioSource>()[6];
        audioCruise     = this.GetComponents <AudioSource>()[5];
        audioSlow       = this.GetComponents <AudioSource>()[7];

        print("Jarvis booting up...");
        keywords.Add("Jarvis", () =>
        {
            GoJarvis();
        });
        keywords.Add("Hyperspeed", () =>
        {
            GoHyperspeed();
        });
        keywords.Add("Cruise", () =>
        {
            GoCruise();
        });
        keywords.Add("Slow", () =>
        {
            GoSlow();
        });
        keywords.Add("Mission", () =>
        {
            GoMission();
        });
        keywords.Add("Thanks", () =>
        {
            GoThanks();
        });
        keywords.Add("Exit", () =>
        {
            GoExit();
        });
        keywords.Add("Some", () =>
        {
            GoSome();
        });

        KeywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
        KeywordRecognizer.OnPhraseRecognized += KeywordRecognizerOnPhrase;
        KeywordRecognizer.Start();
    }
コード例 #7
0
    // Use this for initialization
    void Start()
    {
        if (scanManagerObject == null)
        {
            scanManager = GameObject.Find("ScanManager").GetComponent <ScanManager>();
        }
        else
        {
            scanManager = scanManagerObject.GetComponent <ScanManager>();
        }

        keywords.Add("Main Menu", () =>
        {
            // load main menu scene
            scanManager.LoadScene("MainMenu");
        });

        keywords.Add("Save room", () =>
        {
            // save the current mesh
            scanManager.SaveRoom();
            Debug.Log("Saved room");
        });

        keywords.Add("Save and Quit", () =>
        {
            // save the current mesh
            scanManager.SaveRoom();

            // return to main menu
            scanManager.LoadScene("MainMenu");
        });

        keywords.Add("Stop scanner", () => {
            SpatialMappingManager.Instance.StopObserver();
        });

        keywords.Add("Start scanner", () =>
        {
            SpatialMappingManager.Instance.StartObserver();
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #8
0
 void StartMic()
 {
     if (keywordRecognizer == null)
     {
         TraceHelper.Log("Starting keyword recognizer");
         keywordRecognizer = new KeywordRecognizer(new string[] { "activate", "turn off", "three word phrase" });
         keywordRecognizer.OnPhraseRecognized += (args) =>
         {
             TraceHelper.LogOnUnityThread(string.Format("Phrase: {0}, Conf: {1} ",
                                                        args.text, args.confidence));
         };
         keywordRecognizer.Start();
         TraceHelper.Log("Started keyword recognizer");
     }
 }
コード例 #9
0
    void Start()
    {
        var keywords = new string[_recognizeEvents.Count];

        for (var i = 0; i < keywords.Length; i++)
        {
            keywords[i] = _recognizeEvents[i]._keyword;
        }

        _recognizer = new KeywordRecognizer(keywords, ConfidenceLevel.Medium);
        _recognizer.OnPhraseRecognized += OnPhraseRecognized;
        _recognizer.Start();

        Debug.Log("Keyword recognizer: Listening");
    }
コード例 #10
0
    // Use this for initialization
    void Start()
    {
        keywords.Add("Play", () =>
        {
            // Call the OnReset method on every descendant object.
            this.BroadcastMessage("LoadScene");
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #11
0
    void StartVoice( )
    {
        commands = new Dictionary <string, System.Action>();
        commands.Add("dimensions", OnGetDimensions);
        commands.Add("stationary", OnTryStationary);
        commands.Add("geometry", OnGetGeometry);
        commands.Add("room scale", OnTryRoomscale);
        commands.Add("recenter", OnRecenter);
        commands.Add("positional", OnTogglePositional);
        KeywordRecognizer recognizer = new KeywordRecognizer(commands.Keys.ToArray());

        recognizer.OnPhraseRecognized += Recognizer_OnPhraseRecognized;
        recognizer.Start();
        TraceHelper.Log("voice command started: dimensions, stationary, geometry, room scale, recenter, positional");
    }
コード例 #12
0
    // Use this for initialization
    void Start()
    {
        keywords.Add("Reset Game", () =>
        {
            // Call the OnReset method on every descendant object.
            GameController.Instance.Reset();
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #13
0
    void Start()
    {
        GoHomeSpeechInputs();
        GoToNearestStarInputs();
        GoToRandomStarInputs();
        GoToNearestPlanetInputs();
        CantDoThatInputs();
        HalInputs();

        keywordRecognizer   = new KeywordRecognizer(keywords.Keys.ToArray());
        dictationRecognizer = new DictationRecognizer();
        dictationRecognizer.DictationResult  += TestRawOutput;
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizerOnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #14
0
    void Start()
    {
        // add the strings and associated methods
        actions.Add("pause", PauseGame);
        actions.Add("pause game", PauseGame);
        actions.Add("stop", PauseGame);

        // set the KeywordRecognizer
        keywordRecognizer = new KeywordRecognizer(actions.Keys.ToArray());
        // called when a phrase in the dictionary is recognised
        keywordRecognizer.OnPhraseRecognized += RecognizedSpeech;

        //starts listening
        keywordRecognizer.Start();
    }
コード例 #15
0
    public float speed = 1;                                                          //Speech speed value.

    void Start()
    {
        // Add string play again to restart the game.
        actions.Add("play again", Restart);
        // Add string quit again to quit the game.
        actions.Add("quit", QuitGame);
        // Add string main menu and menu to navigate back to main menu.
        actions.Add("main menu", Back);
        actions.Add("menu", Back);

        //Checks Array of strings
        keywordRecognizer = new KeywordRecognizer(actions.Keys.ToArray(), confidence);
        keywordRecognizer.OnPhraseRecognized += RecognizedSpeech;
        keywordRecognizer.Start();
    }// End of Start method
コード例 #16
0
    // Use this for initialization
    void Start()
    {
        keywords.Add("Open menu", () =>
        {
            // Call the OnReset method on every descendant object.
            GameObject.FindGameObjectWithTag("Menu").GetComponent <MenuColliderScript>().OnOpenCommand();
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #17
0
        protected void StopVoiceCommand()
        {
#if UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
            if (keywordRecognizer != null)
            {
                if (keywordRecognizer.IsRunning)
                {
                    keywordRecognizer.Stop();
                }
                keywordRecognizer.OnPhraseRecognized -= KeywordRecognizer_OnPhraseRecognized;
                keywordRecognizer.Dispose();
                keywordRecognizer = null;
            }
#endif // UNITY_STANDALONE_WIN || UNITY_WSA || UNITY_EDITOR_WIN
        }
コード例 #18
0
ファイル: ScaleManager.cs プロジェクト: LinkCable/HoloHealth
    void Start()
    {
        keywordCollection = new Dictionary <string, KeywordAction>();

        // Add keyword Expand Model to call the ExpandModelCommand function.
        keywordCollection.Add("Expand Model", ExpandModelCommand);

        // Add keyword Reset Model to call the ResetModelCommand function.
        keywordCollection.Add("Contract Model", ContractModelCommand);

        // Initialize KeywordRecognizer with the previously added keywords.
        keywordRecognizer = new KeywordRecognizer(keywordCollection.Keys.ToArray());
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #19
0
 public override void StartListening(string[] commands)
 {
     if (commands != null) //???
     {
         recognizer = new KeywordRecognizer(commands, confidence);
         recognizer.OnPhraseRecognized += Recognizer_OnPhraseRecognized;
         recognizer.Start();
         string list = "";
         foreach (string c in commands)
         {
             list += c + ",";
         }
         Debug.Log("[WinSpeech] awaiting:" + list);
     }
 }
コード例 #20
0
    // Use this for initialization
    void Start()
    {
        // Speech recognition
        keywords.Add("Spawn ball", () =>
        {
            SpawnABall();
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #21
0
    // Use this for initialization
    void Start()
    {
        if (KeysAndActions.Length == 0)
        {
            Debug.Log("Anyone keyword wasn't assigned in " + gameObject.name + ".");
            return;
        }

        dictionary = KeysAndActions.ToDictionary(keysAndActions => keysAndActions.Key,
                                                 keysAndActions => keysAndActions.Event);

        keywordRecognizer = new KeywordRecognizer(dictionary.Keys.ToArray());
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #22
0
    // Start is called before the first frame update
    void Start()
    {
        //Voice commands for playing sound
        keyActs.Add("Hello John Muir", HelloResponse);
        keyActs.Add("questions, John Muir.", AskResponse);
        keyActs.Add("Goodbye John Muir", ByeResponse);
        keyActs.Add("protect places like Yosemite?", ProtectYosemiteResponse);
        keyActs.Add(" one of a kind?", UniqueResponse);
        keyActs.Add("mass deforestation?", PreservationForestResponse);
        keyActs.Add("forest preservation?", PreservationForestResponse);

        recognizer = new KeywordRecognizer(keyActs.Keys.ToArray());
        recognizer.OnPhraseRecognized += OnKeywordsRecognized;
        recognizer.Start();
    }
コード例 #23
0
    // Start is called before the first frame update
    void Start()
    {
        soundSource = GetComponent <AudioSource>();

        //Voice commands for playing sound
        keyActs.Add("Goodbye John Muir", ByeResponse);
        keyActs.Add("protect places like Yosemite", ProtectYosemiteResponse);
        keyActs.Add("one of a kind", UniqueResponse);
        keyActs.Add("mass deforestation", PreservationForestResponse);
        keyActs.Add("forest preservation", PreservationForestResponse);

        recognizer = new KeywordRecognizer(keyActs.Keys.ToArray());
        recognizer.OnPhraseRecognized += OnKeywordsRecognized;
        recognizer.Start();
    }
コード例 #24
0
    // Use this for initialization
    void Start()
    {
        keywords.Add("Main Menu", () =>
        {
            // load main menu scene
            SceneManager.LoadScene("MainMenu");
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #25
0
        void Start()
        {
            actions.Add("I", I);
            actions.Add("want", Want);
            actions.Add("bounty", Bounty);
            actions.Add("sex", Sex);

            actions.Add("Jouer", Jouer);

            keyReco = new KeywordRecognizer(actions.Keys.ToArray());
            keyReco.OnPhraseRecognized += Reco;
            keyReco.Start();

            MenuMana = FindObjectOfType <MainMenuManager>();
        }
コード例 #26
0
ファイル: elevator.cs プロジェクト: sachx1/Escape.exe
    void Start()
    {
        //actions.Add("call", Up);

        //check();
        //keywordRecognizer = new KeywordRecognizer(actions.Keys.ToArray());
        //keywordRecognizer.OnPhraseRecognized += RecgonizedSpeech;
        //keywordRecognizer.Start();
        //check();
        actions.Add("keybox", appear);
        keywordRecognizer = new KeywordRecognizer(actions.Keys.ToArray());
        keywordRecognizer.OnPhraseRecognized += RecgonizedSpeech;
        keywordRecognizer.Start();
        word.SetActive(false);
    }
コード例 #27
0
        /// <inheritdoc />
        public override void Enable()
        {
            if (!Application.isPlaying ||
                (Commands == null) ||
                (Commands.Length == 0))
            {
                return;
            }

            if (InputSystemProfile == null)
            {
                return;
            }

            IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem;

            InputSource = inputSystem?.RequestNewGenericInputSource("Windows Speech Input Source", sourceType: InputSourceType.Voice);

            var newKeywords = new string[Commands.Length];

            for (int i = 0; i < Commands.Length; i++)
            {
                newKeywords[i] = Commands[i].LocalizedKeyword;
            }

            RecognitionConfidenceLevel = InputSystemProfile.SpeechCommandsProfile.SpeechRecognitionConfidenceLevel;

            if (keywordRecognizer == null)
            {
                try
                {
                    keywordRecognizer = new KeywordRecognizer(newKeywords, (ConfidenceLevel)RecognitionConfidenceLevel);
                }
                catch (UnityException ex)
                {
                    Debug.LogWarning($"Failed to start keyword recognizer. Are microphone permissions granted? Exception: {ex}");
                    keywordRecognizer = null;
                    return;
                }

                keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
            }

            if (InputSystemProfile.SpeechCommandsProfile.SpeechRecognizerStartBehavior == AutoStartBehavior.AutoStart)
            {
                StartRecognition();
            }
        }
コード例 #28
0
    // Start is called before the first frame update
    void Start()
    {
        // Create a new Google cloud instance
        _gcTextToSpeech = GCTextToSpeech.Instance;

        // Add success and failure event methods to the current instance
        _gcTextToSpeech.SynthesizeSuccessEvent += _gcTextToSpeech_SynthesizeSuccessEvent;
        _gcTextToSpeech.SynthesizeFailedEvent  += _gcTextToSpeech_SynthesizeFailedEvent;

        // Add the culture info and number format to the provider
        _provider = (CultureInfo)CultureInfo.InvariantCulture.Clone();
        _provider.NumberFormat.NumberDecimalSeparator = ".";

        // Add the chosen voice configuration to _currentVoice
        String[] myTypes = { Enumerators.LanguageCode.en_US.ToString() };
        _currentVoice.languageCodes          = myTypes;
        _currentVoice.name                   = "en-US-Wavenet-A";
        _currentVoice.naturalSampleRateHertz = 24000.0;
        _currentVoice.ssmlGender             = Enumerators.SsmlVoiceGender.MALE;

        using (StreamWriter responsesOutput = new StreamWriter(@"Assets/OutputData/responsesLog" + simulationStart + ".txt", true))
        {
            responsesOutput.WriteLine("--- Log of Keywords and responses in current simulation ---\n");
        }

        //Create instance of myAssistanceBot
        assistanceBot myAssistanceBot = new assistanceBot();

        //Create BotConfig which is object containing new dictionary with key-responses from input JSON file
        BotConfig assistanceBotJSON = myAssistanceBot.ConfParser();

        // Defining a list of keys to iterate over
        List <string> keys = new List <string>(assistanceBotJSON.keywordDict.Keys);

        // loop over each key in the responses dictionary
        foreach (string key in keys)
        {
            // add each key and response to the phrases dictionary
            string response = assistanceBotJSON.keywordDict[key];

            phrases.Add(key, () => { speakResponse(response); });
        }

        // initialize a new keyword recognizer and populate with phrases
        keywordRecognizer = new KeywordRecognizer(phrases.Keys.ToArray());
        keywordRecognizer.OnPhraseRecognized += phraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #29
0
    // Use this for initialization
    void Start()
    {
        /* keywords.Add("Forward", () =>
         * {
         *  this.BroadcastMessage("OnStepForward");
         * }); */

        keywords.Add("Next", () =>
        {
            this.BroadcastMessage("OnStepForward");
        });

        keywords.Add("Back", () =>
        {
            this.BroadcastMessage("OnStepBack");
        });

        /*
         * keywords.Add("Previous", () =>
         * {
         *  this.BroadcastMessage("OnStepBack");
         * });
         */

        keywords.Add("Restart", () =>
        {
            this.BroadcastMessage("OnRestart");
        });

        /*
         * keywords.Add("Start", () =>
         * {
         *  this.BroadcastMessage("OnStart");
         * });
         */

        keywords.Add("Quit", () =>
        {
            this.BroadcastMessage("OnQuitRequested");
        });

        // Tell the KeywordRecognizer about our keywords.
        keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());

        // Register a callback for the KeywordRecognizer and start recognizing!
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
        keywordRecognizer.Start();
    }
コード例 #30
0
        void Start()
        {
            int keywordCount = KeywordsAndResponses.Length;

            //refObj = GameObject.Find("SpeechOnOff");

            /*if (refObj.GetComponent<SpeechOnOff>().OnOff == 1)
             * {
             *  StopKeywordRecognizer();
             * }
             *
             * if (refObj.GetComponent<SpeechOnOff>().OnOff == 0)
             * {
             *  StartKeywordRecognizer();
             * }*/

            if (keywordCount > 0)
            {
                try
                {
                    string[] keywords = new string[keywordCount];
                    // Convert the struct array into a dictionary, with the keywords and the keys and the methods as the values.
                    // This helps easily link the keyword recognized to the UnityEvent to be invoked.
                    for (int index = 0; index < keywordCount; index++)
                    {
                        KeywordAndResponse keywordAndResponse = KeywordsAndResponses[index];
                        responses[keywordAndResponse.Keyword] = keywordAndResponse.Response;
                        keywords[index] = keywordAndResponse.Keyword;
                    }

                    keywordRecognizer = new KeywordRecognizer(keywords);
                    keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;

                    if (RecognizerStart == RecognizerStartBehavior.AutoStart)
                    {
                        keywordRecognizer.Start();
                    }
                }
                catch (ArgumentException)
                {
                    Debug.LogError("Duplicate keywords specified in the Inspector on " + gameObject.name + ".");
                }
            }
            else
            {
                Debug.LogError("Must have at least one keyword specified in the Inspector on " + gameObject.name + ".");
            }
        }
コード例 #31
0
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Script active");
        audioSource = gameObject.GetComponent <AudioSource>();
        actions.Add("Activate Camera Mode", CameraMode);
        actions.Add("Activate Environment Mode", EnvironmentMode);  //rework the spawning mechanic
        actions.Add("Activate God Mode", GodMode);

        actions.Add("Spawn", SpawnItem);
        actions.Add("Tree", SpawnTree);
        actions.Add("Castle", SpawnCastle);
        actions.Add("Pyramid", SpawnPyramid);
        actions.Add("Cactus", SpawnCactus);
        actions.Add("Mountain", SpawnMountain);
        actions.Add("Flower", SpawnFlower);
        actions.Add("Ice Mountain", SpawnIceMountain);
        actions.Add("Palm Tree", SpawnPalmTree);
        actions.Add("Rocks", SpawnRocks);
        actions.Add("Snowy Trees", SpawnSnowyTrees);
        actions.Add("Swamp Tendrils", SpawnSwamp);
        actions.Add("Town", SpawnTown);
        actions.Add("Village", SpawnVillage);
        actions.Add("Human", SpawnHuman);
        actions.Add("Hell Spikes", SpawnHellSpikes);
        actions.Add("Hell Trees", SpawnHellTrees);
        actions.Add("Plant", SpawnPlant);
        actions.Add("Glacier", SpawnGlacier);
        actions.Add("Snowmen", SpawnSnowmen);
        actions.Add("Log", SpawnLog);

        actions.Add("Meteor", SpawnMeteor);
        actions.Add("Fire", SpawnFire);
        actions.Add("Tornado", SpawnTornado);
        actions.Add("Horror", SpawnHorror);


        keywordRecogniser = new KeywordRecognizer(actions.Keys.ToArray());
        keywordRecogniser.OnPhraseRecognized += RecognisedSpeech;
        keywordRecogniser.Start();

        CameraModeHud.SetActive(false);
        EnvironmentModeHud.SetActive(false);
        GodModeHud.SetActive(true);

        EnvGui.SetActive(false);

        GodMode();
    }
コード例 #32
0
        void Start()
        {
            if (KeywordsAndResponses.Length > 0)
            {
                // Convert the struct array into a dictionary, with the keywords and the keys and the methods as the values.
                // This helps easily link the keyword recognized to the UnityEvent to be invoked.
                responses = KeywordsAndResponses.ToDictionary(keywordAndResponse => keywordAndResponse.Keyword,
                                                              keywordAndResponse => keywordAndResponse.Response);

                keywordRecognizer = new KeywordRecognizer(responses.Keys.ToArray());
                keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;

                if (RecognizerStart == RecognizerStartBehavior.AutoStart)
                {
                    keywordRecognizer.Start();
                }
            }
            else
            {
                Debug.LogError("Must have at least one keyword specified in the Inspector on " + gameObject.name + ".");
            }
        }
コード例 #33
0
 void Update()
 {
     if (pristine)
     {
         // Checks to see if machine can use the speech recognition
         if (PhraseRecognitionSystem.isSupported)
         {
             CreateRecognizedCommands();
             m_Recognizer = new KeywordRecognizer(m_Keywords.ToArray());
             m_Recognizer.OnPhraseRecognized += OnPhraseRecognized;
             m_Recognizer.Start();
         }
         // If not, make the speech toggle (in panel) non-interactable.
         else
         {
             PanelController.DeactivateSpeechToggle();
             isSpeech = false;
         }
         pristine = false;
     }
 }