Example #1
0
 private void RecognitionSuccessEventHandler(RecognitionResponse arg1, long arg2)
 {
     if (RecognitionSuccessEvent != null)
     {
         RecognitionSuccessEvent(arg1, arg2);
     }
 }
Example #2
0
        private void RecognizeSuccessEventHandler(RecognitionResponse response)
        {
#if !NET_2_0 && !NET_2_0_SUBSET
            RecognizeSuccessEvent?.Invoke(response);
#else
            if (RecognizeSuccessEvent != null)
            {
                RecognizeSuccessEvent(response);
            }
#endif
        }
Example #3
0
        private void RecognizeSuccessEventHandler(RecognitionResponse response)
        {
            String result = "";

            try
            {
                foreach (var item in response.results[0].alternatives[0].words)
                {
                    result += item.word + " ";
                }
            }
            catch
            {
                Debug.Log("An error occured.");
            }

            UpdateResult(result);
        }
Example #4
0
    // debug
    void newWordsRecongize(FrostweepGames.Plugins.GoogleCloud.SpeechRecognition.RecognitionResponse _obj
                           , long requestIndex)
    {
        if (_obj == null || _obj.results.Length <= 0)
        {
            return;                                              // if no words has been detected
        }
        foreach (var _result in _obj.results)
        {
            foreach (var _alt in _result.alternatives)
            {
                recognized_str.Add(_alt.transcript);
            }
        }

        foreach (var _s in recognized_str)
        {
            Debug.Log("newWordsRecongize:\n" + _s);
        }
    }
        private void SpeechRecognizedSuccessEventHandler(RecognitionResponse obj, long requestIndex)
        {
            if (!run_time_detect_flag)
            {
                _speechRecognitionState.color = Color.green;
            }

            if (obj == null || obj.results.Length < 0)
            {
                _speechRecognitionResult.text = "Speech Recognition succeeded but no words detected.";
            }
            else
            {
                _speechRecognitionResult.text = "Possible words:";
                foreach (var _result in obj.results)
                {
                    foreach (var _alt in _result.alternatives)
                    {
                        _speechRecognitionResult.text += "\n" + _alt.transcript;
                    }
                }
            }
        }
Example #6
0
        private void InsertRecognitionResponseInfo(RecognitionResponse recognitionResponse)
        {
            if (recognitionResponse == null || recognitionResponse.results.Length == 0)
            {
                _resultText.text = "\nWords not detected. Try again";
                //	_startRecordButton.interactable = true;
                //	_startRecordButton.image.sprite = Mike_white;

                //	_speechRecognition.StopRecord();
                return;
            }

            _resultText.text = "You said: " + recognitionResponse.results[0].alternatives[0].transcript + "'";

            var words = recognitionResponse.results[0].alternatives[0].words;

            if (words != null)
            {
                string times = string.Empty;
                string phrase, today;
                actionType      = "";
                seasonParameter = "";
                weatherDate     = DateTime.Now;             // dont know how to reset this!!!



                string[] dayofWeek = { "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" };

                foreach (var item in recognitionResponse.results[0].alternatives[0].words)
                {
                    //times += "<color=green>" + item.word+ "\n";// + "</color> -  start: " + item.startTime + "; end: " + item.endTime + "\n";

                    phrase = item.word;
                    phrase = phrase.ToLower();
                    //_resultText.text += "\n" + phrase;
                    if (phrase.Contains("today") || phrase.Contains("tomorrow") || phrase.Contains("sunday") || phrase.Contains("monday") || phrase.Contains("tuesday") || phrase.Contains("wednesday") || phrase.Contains("thursday") || phrase.Contains("friday") || phrase.Contains("saturday"))
                    {
                        actionType = "weather";

                        if (phrase.Contains("today"))
                        {
                            phrase      = "today";
                            weatherDate = DateTime.Now;
                        }
                        else if (phrase.Contains("tomorrow"))
                        {
                            phrase      = "tomorrow";
                            weatherDate = DateTime.Now.AddDays(1);
                        }

                        else
                        {
                            today  = DateTime.Now.DayOfWeek.ToString();
                            today  = today.ToLower();
                            phrase = phrase.Replace("?", String.Empty).Replace("'s", String.Empty).Replace(".", String.Empty).Replace(",", String.Empty);
                            phrase = phrase.ToLower();

                            int index1     = Array.IndexOf(dayofWeek, phrase);
                            int indexToday = Array.IndexOf(dayofWeek, today);
                            //_resultText.text += "\n index 1=" + index1 + "indexToday=" + indexToday + "today is: " + today;

                            if (index1 > indexToday)
                            {
                                weatherDate = DateTime.Now.AddDays(index1 - indexToday);
                            }
                            else if (index1 < indexToday)
                            {
                                weatherDate = DateTime.Now.AddDays(index1 - indexToday + 7);
                            }                                                                                                                          // if its a earlier day than today, calculate the next week's same day
                            else
                            {
                                weatherDate = DateTime.Now;
                            }
                        }
                    }
                    else if (phrase.Contains("summer") || phrase.Contains("autumn") || phrase.Contains("spring") || phrase.Contains("sun") || phrase.Contains("sunny") || phrase.Contains("winter"))
                    {
                        phrase = phrase.Replace("?", String.Empty).Replace("'s", String.Empty).Replace(".", String.Empty).Replace(",", String.Empty);
                        phrase = phrase.ToLower();

                        actionType      = "season";
                        seasonParameter = phrase;
                    }
                }

                // step 1 - Call getWeather(DateTime wdate) APIs to get weather status (return object would have a seasons parameter)
                // step 2 - call video player to change "showWeather" showWeather(string actionType, string seasonParameter)

                /*		times += "ActionType = " + actionType + "\n"
                 + "seasonParameter = " + seasonParameter + "\n"
                 + "weatherDate = " + weatherDate + "\n";
                 +
                 +              _resultText.text += "\n" + times;
                 */
                //call this only if actionType=season, else call katerina's script
                if (actionType == "season")
                {
                    getSeason(seasonParameter);
                }
                else if (actionType == "weather")
                {
                    getWeather(weatherDate);
                }
                else
                {
                    _resultText.text += "\n Ask for e.g what's the weather tomorrow";
                }
            }

            _startRecordButton.interactable = true;
            _startRecordButton.image.sprite = Mike_white;

            _speechRecognition.StopRecord();
            actionType      = "";
            seasonParameter = "";
        }
Example #7
0
 private void RecognizeSuccessEventHandler(RecognitionResponse recognitionResponse)
 {
     //_resultText.text = "Recognize Success.";
     InsertRecognitionResponseInfo(recognitionResponse);
 }