示例#1
0
 private void IS_Health_Potion()
 {
     if (itemSkillRecognizer.IsRunning)
     {
         itemSkillRecognizer.Stop();
     }
 }
    void Update()
    {
        actualOrderTime += Time.deltaTime;
        if (recognizerIsActive)
        {
            if (actualOrderTime >= maxOrderTime - 0.1)
            {
                if ((int)PhotonNetwork.LocalPlayer.CustomProperties["Lifes"] > 0)
                {
                    if (orderIsSimon && orderPlayers.Contains(OnlineGameManager.instance.playerName))
                    {
                        recognizer.Stop();

                        if (PhotonNetwork.LocalPlayer.CustomProperties.ContainsKey("Lifes"))
                        {
                            ExitGames.Client.Photon.Hashtable newProperties = new ExitGames.Client.Photon.Hashtable();
                            newProperties.Add("Lifes", ((int)PhotonNetwork.LocalPlayer.CustomProperties["Lifes"]) - 1);
                            PhotonNetwork.LocalPlayer.SetCustomProperties(newProperties);
                        }
                    }
                    else
                    {
                        OnlineGameManager.instance.UpdatePlayersScore(100);
                    }
                    recognizerIsActive = false;
                }
            }
        }
    }
示例#3
0
    private void OnPhraserecognized(PhraseRecognizedEventArgs args)
    {
        string sceneName = SceneManager.GetActiveScene().name;
        float  newX      = Random.Range(-3, 3);
        float  newZ      = Random.Range(-3, 3);

        if (args.text == m_keywords[0])
        {
            SceneManager.LoadScene(sceneName, LoadSceneMode.Single);
            m_recognizer.Stop();
            m_recognizer.Dispose();
            Start();
        }

        if (args.text == m_keywords2[0])
        {
            mower.GetMowerMovementData();
            mower.GetMowerRotationData();
            mower.StartCoroutine(mower.MowerMove(mower.mowerMovement));
            ghost.GetGhostMovementData();
            ghost.GetGhostRotationData();
            ghost.StartCoroutine(ghost.GhostMove(ghost.ghostMovement));
            m_recognizer2.Stop();
            m_recognizer2.Dispose();
            Start();
        }

        if (args.text == m_keywords3[0])
        {
            mower.startsimulation();
            m_recognizer2.Stop();
            m_recognizer2.Dispose();
            Start();
        }
    }
示例#4
0
 private void SS_Solid_Strike()
 {
     if (swordSkillRecognizer.IsRunning)
     {
         swordSkillRecognizer.Stop();
     }
 }
示例#5
0
 private void CC_Direct_Link()
 {
     if (commSkillRecognizer.IsRunning)
     {
         commSkillRecognizer.Stop();
     }
 }
示例#6
0
 private void RecognizedSpeechY(PhraseRecognizedEventArgs speech)
 {
     Debug.Log(speech.text);
     y = Convert.ToInt32(speech.text);
     if (y <= gridY)
     {
         Tile temp = ReturnTile(x - 1, y - 1);
         if (temp.IsWalkable)
         {
             keywordRecognizer2.Stop();
             Mueve(x, y);
             FindObjectOfType <AudioManager>().Play("posInicioModif");
             keywordRecognizer2.OnPhraseRecognized -= RecognizedSpeechY;
             keywordRecognizer.Start();
         }
         else
         {
             FindObjectOfType <AudioManager>().Play("errorFilaInicio");
         }
     }
     else
     {
         FindObjectOfType <AudioManager>().Play("errorFilaInicio");
     }
 }
示例#7
0
    private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
    {
        Action keywordAction;

        // if the keyword recognized is in our dictionary, call that Action.
        if (keywordDictionary.TryGetValue(args.text, out keywordAction))
        {
            Debug.Log(args.text + " recognized. Action invoked " + keywordAction.ToString());
            //foreach (GrammarMapper gm in gMapper) { Debug.Log(gm.ToString()); }
            for (int i = 0; i < gMapper.Count; i++)
            {
                if (gMapper[i].Equals(new GrammarMapper {
                    item = args.text, jumpTo = 0
                }))
                {
                    Debug.Log("Response jump to: " + gMapper[i].jumpTo);
                    interactionManager.eventIndex = gMapper[i].jumpTo;
                    keywordRecognizer.Stop();
                    keywordRecognizer.Dispose();
                    interactionManager.isListening = false;
                    keywordDictionary.Clear();
                    gMapper.Clear();
                    keywordAction.Invoke();
                }
            }
        }
    }
示例#8
0
    }//End of start method.

    // Stops keywordRecognizer when quits application.
    private void OnApplicationQuit()
    {
        if (keywordRecognizer != null && keywordRecognizer.IsRunning)
        {
            keywordRecognizer.OnPhraseRecognized -= RecognizedSpeech;
            keywordRecognizer.Stop();
        }
    }// End of OnApplicationQuit method.
示例#9
0
 void OnApplicationQuit()
 {
     if (recognizer != null && recognizer.IsRunning)
     {
         recognizer.OnPhraseRecognized -= Recognizer_OnPhraseRecognized;
         recognizer.Stop();
     }
 }
 private void Deactivate()
 {
     if (state)
     {
         micOn--;
         if (micOn == 0)
         {
             mic.Stop();
         }
         state = false;
     }
     Debug.LogFormat("[Crazy Speak #{0}] Needy deactivated.", _id);
 }
 public void shutdown()
 {
     if (keywordRecognizer != null)
     {
         keywordRecognizer.OnPhraseRecognized -= KeywordRecognizer_OnPhraseRecognized;
         keywordRecognizer.Stop();
         keywordRecognizer.Dispose();
     }
     PhraseRecognitionSystem.Shutdown();
     gameObject.SetActive(false);
     canvasGO.SetActive(false);
     cursorGO.SetActive(false);
 }
示例#12
0
 void Update()
 {
     actualOrderTime += Time.deltaTime;
     if (active)
     {
         if (actualOrderTime >= maxOrderTime - 0.1)
         {
             orderGenerator.UpdateLifes();
             recognizer.Stop();
             active = false;
         }
     }
 }
示例#13
0
 public void ChangeKeyWords(String[] keywords)
 {
     if (keywordRecognizer != null)
     {
         keywordRecognizer.Stop();
         keywordRecognizer.Dispose();
     }
     if (keywords.Length != 0)
     {
         keywordRecognizer = new KeywordRecognizer(keywords.ToArray());
         keywordRecognizer.OnPhraseRecognized += onKeywordRecognized;
         keywordRecognizer.Start();
     }
 }
示例#14
0
    /// <summary>
    /// Runs at initialization right after Awake method
    /// </summary>
    void Start()
    {
        // 登録されたタグの一覧の取得
        Array tagsArray = Enum.GetValues(typeof(CustomVisionTrainer.Tags));

        foreach (object tagWord in tagsArray)
        {
            _keywords.Add(tagWord.ToString(), () =>
            {
                // 登録されたタグがキーワードとして認識されると、Custom Vision Serviceの学習を行うアクションを登録
                CustomVisionTrainer.Instance.VerifyTag(tagWord.ToString());
            });
        }

        _keywords.Add("キャンセル", () =>
        {
            // キャンセルというキーワードが認識されると、キャプチャした写真をリセットし、キーワードレコナイザーを停止するアクションを登録
            ImageCapture.Instance.ResetImageCapture();
            keywordRecognizer.Stop();
        });

        // キーワードレコナイザーの生成
        keywordRecognizer = new KeywordRecognizer(_keywords.Keys.ToArray());

        // キーワードを認識したときのイベントハンドラを登録
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
    }
示例#15
0
        public void initKeywordsWithRooms()
        {
            keywords2 = new Dictionary <string, System.Action>();
            var keylist = rman.linkcloudctrl.GetKeywordKeys();
            int nadded  = 0;

            foreach (var key in keylist)
            {
                var val = rman.linkcloudctrl.GetKeywordValue(key);
                keywords2.Add(key, () => { rman.NodeAction(val); });
                nadded += 1;
                RouteMan.Log("Adding key:" + key + "  Val:" + val);
            }
            if (kR2 != null)
            {
                kR2.Stop();
                kR2.Dispose();
                kR2 = null;
            }
            if (keywords2.Count > 0)
            {
                kR2 = new KeywordRecognizer(keywords2.Keys.ToArray());
                kR2.OnPhraseRecognized += kROnPhraseRecognized2;
                kR2.Start();
            }
            RouteMan.Log("keywords rooms num keys:" + keywords2.Count);
        }
示例#16
0
    //right click to exit text
    private void Update()
    {
        if (keywordRecognizer != null)
        {
            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                keywordRecognizer.Stop();
                keywordRecognizer = null;
                canRead           = false;


                // text.SetActive(false);
                Destroy(textLocal);

                PlayShooting();
            }
        }

        if (isPlaying == true)
        {
            if (audioPlayer.isPlaying == false)
            {
                SceneManager.LoadScene(nextScene);
            }
        }
    }
 private void WindowsStopRecognition()
 {
     if (keywordRecognizer != null && keywordRecognizer.IsRunning)
     {
         keywordRecognizer.Stop();
     }
 }
 private void OnDestroy()
 {
     if (keywordRecognizer != null)
     {
         keywordRecognizer.Stop();
     }
 }
示例#19
0
 void OnDisable()
 {
     if (keywordRecognizer != null && keywordRecognizer.IsRunning)
     {
         keywordRecognizer.Stop();
     }
 }
 private void SetKeywordListener(bool listen)
 {
     if (listen)
     {
         if (KeywordRequiresGaze && mKeywordArray != null)
         {
             if (mKeywordRecognizer == null)
             {
                 mKeywordRecognizer = new KeywordRecognizer(mKeywordArray);
                 mKeywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
                 mKeywordRecognizer.Start();
             }
             else
             {
                 if (!mKeywordRecognizer.IsRunning)
                 {
                     mKeywordRecognizer.Start();
                 }
             }
         }
     }
     else
     {
         if (mKeywordRecognizer != null && KeywordRequiresGaze)
         {
             if (mKeywordRecognizer.IsRunning)
             {
                 mKeywordRecognizer.Stop();
                 mKeywordRecognizer.OnPhraseRecognized -= KeywordRecognizer_OnPhraseRecognized;
                 mKeywordRecognizer.Dispose();
                 mKeywordRecognizer = null;
             }
         }
     }
 }
示例#21
0
 public void PauseRecognition()
 {
     if (recognizer != null && recognizer.IsRunning)
     {
         recognizer.Stop();
     }
 }
示例#22
0
        private void PrepareStartStopRecognition()
        {
            var startListening = new Dictionary <string, Action>
            {
                {
                    "do", () =>
                    {
                        Debug.LogWarning("Start Listening");
                        Recognizer.Start();
                    }
                },
                {
                    "stop", () =>
                    {
                        Debug.LogWarning("Stop Listening");
                        Recognizer.Stop();
                    }
                }
            };

            KeywordRecognizer = new KeywordRecognizer(startListening.Keys.ToArray());
            KeywordRecognizer.OnPhraseRecognized += args =>
            {
                Action action;
                if (startListening.TryGetValue(args.text, out action))
                {
                    action();
                }
            };
        }
示例#23
0
    /// <summary>
    /// Runs at initialization right after Awake method
    /// </summary>
    void Start()
    {
        Array tagsArray = Enum.GetValues(typeof(CustomVisionTrainer.Tags));

        foreach (object tagWord in tagsArray)
        {
            _keywords.Add(tagWord.ToString(), () =>
            {
                // When a word is recognized, the following line will be called
                CustomVisionTrainer.Instance.VerifyTag(tagWord.ToString());
            });
        }

        _keywords.Add("Discard", () =>
        {
            // When a word is recognized, the following line will be called
            // The user does not want to submit the image
            // therefore ignore and discard the process
            ImageCapture.Instance.ResetImageCapture();
            keywordRecognizer.Stop();
        });

        //Create the keyword recognizer
        keywordRecognizer = new KeywordRecognizer(_keywords.Keys.ToArray());

        // Register for the OnPhraseRecognized event
        keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
    }
    private IEnumerator _toggleDictation(bool state)
    {
        if (state)
        {
            keywordRecognizer.Stop();
            PhraseRecognitionSystem.Shutdown();

            while (PhraseRecognitionSystem.Status == SpeechSystemStatus.Running)
            {
                yield return(null);
            }

            dictationRecognizer.Start();
        }
        else
        {
            dictationRecognizer.Stop();

            while (dictationRecognizer.Status == SpeechSystemStatus.Running)
            {
                yield return(null);
            }

            PhraseRecognitionSystem.Restart();
            keywordRecognizer.Start();
        }
    }
        /// <summary>
        /// Adds a listener to a particular voice command
        /// </summary>
        /// <param name="command">command to listen for</param>
        /// <param name="callback">callback executed when command is said</param>
        public void ListenForCommand(string command, KeywordAction callback)
        {
            // Get the list of callbacks associated with this command
            List <KeywordAction> callbacks;

            if (!_commandToFunctionMap.TryGetValue(command, out callbacks))
            {
                // If no callbacks exist, create a new list
                _commandToFunctionMap[command] = callbacks = new List <KeywordAction>();

                // and start listening for this command
                {
                    // Get rid of the current recognizer if it exists
                    if (_recognizer != null)
                    {
                        _recognizer.Stop();
                        _recognizer.Dispose();
                    }

                    // Create a new recognizer that listens for our new command (and all existing commands)
                    _recognizer = new KeywordRecognizer(_commandToFunctionMap.Keys.ToArray());
                    _recognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
                    _recognizer.Start();
                }
            }

            // Save the callback
            callbacks.Add(callback);
        }
示例#26
0
 /// <summary>
 /// Make sure the keyword recognizer is on, then stop it.
 /// Otherwise, leave it alone because it's already in the desired state.
 /// </summary>
 public void StopKeywordRecognizer()
 {
     if (keywordRecognizer != null && keywordRecognizer.IsRunning)
     {
         keywordRecognizer.Stop();
     }
 }
示例#27
0
 private void ResumeGame(PhraseRecognizedEventArgs args)
 {
     StartRecognizers();
     HelpText.gameObject.SetActive(true);
     HelpScreen.SetActive(false);
     keywordRecognizerHelp.Stop();
 }
示例#28
0
    IEnumerator MenuTimer()
    {
        yield return(new WaitForSeconds(10.0f));

        _menuRecognizer.Stop();
        _activateFlag = false;
    }
 /// <inheritdoc />
 public override void StopRecognition()
 {
     if (keywordRecognizer.IsRunning)
     {
         keywordRecognizer.Stop();
     }
 }
    /// <summary>
    /// This Update function is used to start collecting spoken keywords when 'Y' is pressed, and ending this process, thus starting
    /// the demo, when 'N' is pressed.
    /// </summary>
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Y) && !gettingNames)
        {
            actionNames.Clear();
            actionCount = 0;
            eraseSpheres();

            textMesh.text      = "Functions:\n";
            transform.position = Vector3.zero;

            collectingFeedback.gameObject.SetActive(true);
            commandList.gameObject.SetActive(true);

            keywordRecognizer.Start();
            gettingNames = true;
        }

        if ((Input.GetKeyDown(KeyCode.N) || actionNames.Count >= 7) && gettingNames)
        {
            collectingFeedback.gameObject.SetActive(false);
            commandList.gameObject.SetActive(false);

            keywordRecognizer.Stop();
            gettingNames = false;
            runActions();
        }
    }