// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("WebGL Speech Detection Plugin is not set!"); yield break; } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } // subscribe to events _mSpeechDetectionPlugin.AddListenerOnDetectionResult(HandleDetectionResult); // A list of words to detect string[] wordsToDetect = { "Climb", "Crouch", "Jump", "Left", "Right", "Stand", "Run", "10", // match 10 before 1 "Ten", "1", "One", "2", "Two", "3", "Three", "4", "Four", "5", "Five", "6", "Six", "7", "Seven", "8", "Eight", "9", "Nine", }; foreach (string word in wordsToDetect) { _mWords.Add(word.ToLower()); } }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("WebGL Speech Detection Plugin is not set!"); yield break; } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } // subscribe to events _mSpeechDetectionPlugin.AddListenerOnDetectionResult(HandleDetectionResult); }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("Proxy Speech Detection Plugin is not set!"); yield break; } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } // no need to display a warning if the plugin is available SpeechDetectionUtils.SetActive(false, _mTextWaiting); // display the UI controls SpeechDetectionUtils.SetActive(true, _mDropDownDialects, _mDropDownLanguages, _mTextDictation, _mTextSummary); // subscribe to events _mSpeechDetectionPlugin.AddListenerOnDetectionResult(HandleDetectionResult); // Get languages from plugin, _mSpeechDetectionPlugin.GetLanguages((languageResult) => { _mLanguageResult = languageResult; // prepare the language drop down items SpeechDetectionUtils.PopulateLanguagesDropdown(_mDropDownLanguages, _mLanguageResult); // subscribe to language change events if (_mDropDownLanguages) { _mDropDownLanguages.onValueChanged.AddListener(delegate { SpeechDetectionUtils.HandleLanguageChanged(_mDropDownLanguages, _mDropDownDialects, _mLanguageResult, _mSpeechDetectionPlugin); }); } // subscribe to dialect change events if (_mDropDownDialects) { _mDropDownDialects.onValueChanged.AddListener(delegate { SpeechDetectionUtils.HandleDialectChanged(_mDropDownDialects, _mLanguageResult, _mSpeechDetectionPlugin); }); } // Disabled until a language is selected SpeechDetectionUtils.DisableDialects(_mDropDownDialects); // set the default language SpeechDetectionUtils.RestoreLanguage(_mDropDownLanguages); // set the default dialect SpeechDetectionUtils.RestoreDialect(_mDropDownDialects); }); }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("Proxy Speech Detection Plugin is not set!"); yield break; } // proxy needs to be launched before it's available if (_mButtonLaunchProxy) { _mButtonLaunchProxy.onClick.AddListener(() => { _mSpeechDetectionPlugin.ManagementLaunchProxy(); }); } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } if (_mButtonCloseBrowserTab) { _mButtonCloseBrowserTab.onClick.AddListener(() => { _mSpeechDetectionPlugin.ManagementCloseBrowserTab(); }); } if (_mButtonCloseProxy) { _mButtonCloseProxy.onClick.AddListener(() => { _mSpeechDetectionPlugin.ManagementCloseProxy(); }); } if (_mButtonOpenBrowserTab) { _mButtonOpenBrowserTab.onClick.AddListener(() => { _mSpeechDetectionPlugin.ManagementOpenBrowserTab(); }); } if (_mButtonSetProxyPort && _mInputPort) { _mButtonSetProxyPort.onClick.AddListener(() => { int port; if (int.TryParse(_mInputPort.text, out port)) { _mSpeechDetectionPlugin.ManagementSetProxyPort(port); } else { _mInputPort.text = "5000"; } }); } }
// Use this for initialization IEnumerator Start() { // get the singleton instance _mSpeechDetectionPlugin = SpeechDetectionUtils.GetInstance(); // check the reference to the plugin if (null == _mSpeechDetectionPlugin) { Debug.LogError("WebGL Speech Detection Plugin is not set!"); yield break; } // wait for plugin to become available while (!_mSpeechDetectionPlugin.IsAvailable()) { yield return(null); } // no need to display a warning if the plugin is available SpeechDetectionUtils.SetActive(false, _mTextWarning); // make the dropdowns non-interactive SpeechDetectionUtils.SetInteractable(false, _mDropDownLanguages, _mDropDownDialects); // show UI controls SpeechDetectionUtils.SetActive(true, _mDropDownDialects, _mDropDownLanguages, _mImageWords, _mTextSummary); // subscribe to events _mSpeechDetectionPlugin.AddListenerOnDetectionResult(HandleDetectionResult); // Get languages from plugin, _mSpeechDetectionPlugin.GetLanguages((languageResult) => { _mLanguageResult = languageResult; // prepare the language drop down items SpeechDetectionUtils.PopulateLanguagesDropdown(_mDropDownLanguages, _mLanguageResult); // make the dropdowns interactive SpeechDetectionUtils.SetInteractable(true, _mDropDownLanguages, _mDropDownDialects); // subscribe to language change events if (_mDropDownLanguages) { _mDropDownLanguages.onValueChanged.AddListener(delegate { SpeechDetectionUtils.HandleLanguageChanged(_mDropDownLanguages, _mDropDownDialects, _mLanguageResult, _mSpeechDetectionPlugin); }); } // subscribe to dialect change events if (_mDropDownDialects) { _mDropDownDialects.onValueChanged.AddListener(delegate { SpeechDetectionUtils.HandleDialectChanged(_mDropDownDialects, _mLanguageResult, _mSpeechDetectionPlugin); }); } // Disabled until a language is selected SpeechDetectionUtils.DisableDialects(_mDropDownDialects); // set the default language SpeechDetectionUtils.RestoreLanguage(_mDropDownLanguages); // set the default dialect SpeechDetectionUtils.RestoreDialect(_mDropDownDialects); }); // get all the words in the UI foreach (Example02Word word in GameObject.FindObjectsOfType <Example02Word>()) { Text text = word.GetComponentInChildren <Text>(); if (text) { _mWords[text.text.ToLower()] = word; } } }