private void IntentRecognizer_Recognized(object sender, IntentRecognitionEventArgs e) { if (e.Result.Reason == ResultReason.NoMatch) { return; } var json = e.Result.Properties.GetProperty(PropertyId.LanguageUnderstandingServiceResponse_JsonResult); if (!string.IsNullOrEmpty(json)) { var jsonObject = JObject.Parse(json); var entities = jsonObject.GetValue("entities").ToObject <IEnumerable <RecognizedEntity> >(); var topIntent = jsonObject.GetValue("topScoringIntent").ToObject <RecognizedIntent>(); var query = jsonObject.GetValue("query").ToString(); var textParts = ExtractTextParts(entities, query); this.IntentRecognized?.Invoke(new RecognitionResult() { Intent = e.Result.IntentId, Text = query, IsRecognizing = false, Entities = entities, TextParts = textParts, Score = topIntent.Score }); } }
private void Recognizer_Recognized(object sender, IntentRecognitionEventArgs e) { if (e.Result.Reason == ResultReason.RecognizedIntent) { Debug.Log($"RECOGNIZED: Text={e.Result.Text}"); Debug.Log($" Intent Id: {e.Result.IntentId}."); string json = e.Result.Properties.GetProperty(PropertyId.LanguageUnderstandingServiceResponse_JsonResult); Debug.Log($" Language Understanding JSON: {json}."); result = json.FromJson <IntentResult>(); if (result != null) { readyToProcess = true; } } else if (e.Result.Reason == ResultReason.RecognizedSpeech) { readyToProcess = false; Debug.Log($"RECOGNIZED: Text={e.Result.Text}"); Debug.Log($" Intent not recognized."); } else if (e.Result.Reason == ResultReason.NoMatch) { readyToProcess = false; Debug.Log($"NOMATCH: Speech could not be recognized."); } }
private Boolean ProcessRecognizedText(object s, IntentRecognitionEventArgs e) { Boolean exit = false; if (e.Result.Reason == ResultReason.RecognizedIntent) { // Console.WriteLine($"Recognized Text: {e.Result.Text}"); // Console.WriteLine($"Detected Intent: {e.Result.IntentId}"); var rawJason = e.Result.Properties.GetProperty(PropertyId.LanguageUnderstandingServiceResponse_JsonResult); LuisWrapper luisResponse = JsonConvert.DeserializeObject <LuisWrapper>(rawJason); // Get intent and process entities exit = ProcessResponse(luisResponse); } else if (e.Result.Reason == ResultReason.RecognizedSpeech) { Console.WriteLine($"Recognized Text: {e.Result.Text}"); Console.WriteLine($"Detected Intent: <No Intent>"); if (e.Result.Text.ToUpper().Contains("EXIT") || e.Result.Text.ToUpper().Contains("WINDOW")) { exit = true; } } else { Console.WriteLine("Speech could not be recognized."); exit = false; } return(exit); }
private void RecognizingHandler(object sender, IntentRecognitionEventArgs e) { if (e.Result.Reason == ResultReason.RecognizingSpeech) { UnityEngine.Debug.LogFormat($"HYPOTHESIS: Text={e.Result.Text}"); lock (threadLocker) { recognizedString = $"HYPOTHESIS: {Environment.NewLine}{e.Result.Text}"; } } }
private void IntentRecognizer_Recognizing(object sender, IntentRecognitionEventArgs e) { if (e.Result.Reason == ResultReason.NoMatch) { return; } this.IntentRecognized?.Invoke(new RecognitionResult() { Intent = e.Result.IntentId, Text = e.Result.Text, IsRecognizing = true }); }
private void RecognizedHandler(object sender, IntentRecognitionEventArgs e) { if (e.Result.Reason == ResultReason.RecognizedIntent) { //Console.WriteLine($" Language Understanding JSON: {e.Result.Properties.GetProperty(PropertyId.LanguageUnderstandingServiceResponse_JsonResult)}."); UnityEngine.Debug.LogFormat($"RECOGNIZED: Intent={e.Result.IntentId} Text={e.Result.Text}"); lock (threadLocker) { recognizedString = $"RESULT: Intent={e.Result.IntentId}"; string json = e.Result.Properties.GetProperty(PropertyId.LanguageUnderstandingServiceResponse_JsonResult); var result = json.FromJson <IntentResult>(); if (result != null) { recognizedString += $" [Confidence={result.topScoringIntent.score.ToString("0.000")}]"; if (result.entities.Count > 0) { recognizedString += $"{Environment.NewLine}Entities="; for (int i = 0; i < result.entities.Count; i++) { recognizedString += $"[{result.entities[i].type}: {result.entities[i].entity}] "; } } lock (threadLocker) { intent = result; isIntentReady = true; } } recognizedString += $"{Environment.NewLine}{e.Result.Text}"; } } if (e.Result.Reason == ResultReason.RecognizedSpeech) { UnityEngine.Debug.LogFormat($"RECOGNIZED: Text={e.Result.Text}"); lock (threadLocker) { recognizedString = $"RESULT: {Environment.NewLine}{e.Result.Text}"; } } else if (e.Result.Reason == ResultReason.NoMatch) { UnityEngine.Debug.LogFormat($"NOMATCH: Speech could not be recognized."); } }
private void Recognizer_Recognizing(object sender, IntentRecognitionEventArgs e) { readyToProcess = false; Debug.Log($"Recognizing: {e.Result.Text}"); }