private void OnRecognize(SpeechRecognitionEvent result, Dictionary <string, object> customData) { if (result != null && result.results.Length > 0) { foreach (var res in result.results) { foreach (var alt in res.alternatives) { string text = string.Format("{0} ({1}, {2:0.00})\n", alt.transcript, res.final ? "Final" : "Interim", alt.confidence); Log.Debug("ExampleStreaming.OnRecognize()", text); text_scroll.addline(alt.transcript, "joy"); //ResultsField.text = text; // ENTERING THE TONE ZONE - when the utterance contains this word //if (alt.transcript.Contains ("feel") | alt.transcript.Contains ("you") | alt.transcript.Contains ("Jimmy") | alt.transcript.Contains ("robot")) { if (true) { // if the utterance string GHI = alt.transcript; if (!_toneAnalyzer.GetToneAnalyze(OnGetToneAnalyze, OnFail, GHI)) { //Log.Debug ("ExampleToneAnalyzer.Examples()", "Failed to analyze!"); Log.Debug("ExampleToneAnalyzer.Examples()", "NESTED TONE ZONE branch complete."); } //ResultsField.text = "tone analyzed! 111"; // TEST END } // ENTERING THE TONE ZONE - when the utterance contains this word if (alt.transcript.Contains("reset")) { bar1JoyRenderer.transform.localScale = new Vector3(1F, 1F, 1F); bar2SadnessRenderer.transform.localScale = new Vector3(1F, 1F, 1F); bar3FearRenderer.transform.localScale = new Vector3(1F, 1F, 1F); bar4DisgustRenderer.transform.localScale = new Vector3(1F, 1F, 1F); bar5AngerRenderer.transform.localScale = new Vector3(1F, 1F, 1F); } } if (res.keywords_result != null && res.keywords_result.keyword != null) { foreach (var keyword in res.keywords_result.keyword) { Log.Debug("ExampleStreaming.OnRecognize()", "keyword: {0}, confidence: {1}, start time: {2}, end time: {3}", keyword.normalized_text, keyword.confidence, keyword.start_time, keyword.end_time); //ResultsField.text = "tone analyzed! 222"; } } if (res.word_alternatives != null) { foreach (var wordAlternative in res.word_alternatives) { //Log.Debug("ExampleStreaming.OnRecognize()", "Word alternatives found. Start time: {0} | EndTime: {1}", wordAlternative.start_time, wordAlternative.end_time); //foreach(var alternative in wordAlternative.alternatives) //Log.Debug("ExampleStreaming.OnRecognize()", "\t word: {0} | confidence: {1}", alternative.word, alternative.confidence); } } } } }