Intent Recognizer Function for clearing Intent dictionary

dev
Nadine Ganz 2024-09-17 14:44:02 +02:00
parent 2a0e72ec07
commit e6d0accd34
3 changed files with 195880 additions and 192364 deletions

View File

@ -25,7 +25,11 @@ Tree("32_Grotto_Chatbot_Test") {
Composite(Sequence) { Composite(Sequence) {
BTC.Wait(5) BTC.Wait(5)
BTC.CompareUserSpeechInputStarted(false) BTC.CompareUserSpeechInputStarted(false)
RunTree("32_Grotto_Chatbot_Test_No_Answer") BTC.StopSpeechIntentRecognition()
BTC.ClearPossbileSpeechIntents()
// Bilder Bergell
//BTC.Run("LoadScene.NEXT.35Slideshow")
} }
} }
} }
@ -41,11 +45,13 @@ Tree("32_Grotto_Chatbot_Test_Compare_Intent") {
Composite(Race) { Composite(Race) {
Composite(Sequence) { Composite(Sequence) {
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2") BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
BTC.ClearPossbileSpeechIntents()
BTC.GetKeyDown("Return") BTC.GetKeyDown("Return")
// ... // ...
} }
Composite(Sequence) { Composite(Sequence) {
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4") BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
BTC.ClearPossbileSpeechIntents()
BTC.GetKeyDown("Return") BTC.GetKeyDown("Return")
// ... // ...
} }
@ -63,11 +69,13 @@ Tree("32_Grotto_Chatbot_Test_Compare_Intent") {
Composite(Race) { Composite(Race) {
Composite(Sequence) { Composite(Sequence) {
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2") BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
BTC.ClearPossbileSpeechIntents()
BTC.GetKeyDown("Return") BTC.GetKeyDown("Return")
// ... // ...
} }
Composite(Sequence) { Composite(Sequence) {
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4") BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
BTC.ClearPossbileSpeechIntents()
BTC.GetKeyDown("Return") BTC.GetKeyDown("Return")
// ... // ...
} }
@ -80,14 +88,6 @@ Tree("32_Grotto_Chatbot_Test_Compare_Intent") {
} }
} }
Tree("32_Grotto_Chatbot_Test_No_Answer") {
Composite(Sequence) {
// Bilder Bergell
BTC.StopSpeechIntentRecognition()
//BTC.Run("LoadScene.NEXT.35Slideshow")
}
}
Tree("32_Grotto_Kueche_Intro") { Tree("32_Grotto_Kueche_Intro") {
Composite(Sequence) { Composite(Sequence) {
BTC.Run("AudioSource.AUDIO.Kueche1FIntro") BTC.Run("AudioSource.AUDIO.Kueche1FIntro")

View File

@ -609,28 +609,21 @@ public class BTC : MonoBehaviour {
#endif #endif
#endregion #endregion
#region SpeechRecognizer #region Speech Intent Recognizer
private ViaggioAIManager _speechMng { get { return ViaggioAIManager.Instance; } } private ViaggioAIManager _speechMng { get { return ViaggioAIManager.Instance; } }
private RequestDataModel _requestDataModel = new RequestDataModel(); private RequestDataModel _requestDataModel = new RequestDataModel();
private string _recognizedIntentID = ""; private string _recognizedIntentID = "";
private bool _onIntentRecognitionInitiatedEventTriggered = false;
private bool _onIntentRecognitionSucceededEventTriggered = false; private bool _onIntentRecognitionSucceededEventTriggered = false;
private bool _onUserSpeechInputStartedEventTriggered = false; private bool _onUserSpeechInputStartedEventTriggered = false;
private bool _onIntentRecognitionFailedEventTriggered = false; private bool _onIntentRecognitionFailedEventTriggered = false;
private void OnEnable() private void OnEnable()
{ {
_speechMng.OnIntentRecognitionInitiatedEvent += IntentRecognitionInitiatedEventHandler;
_speechMng.OnIntentRecognitionSucceededEvent += IntentRecognitionSucceededEventHandler; _speechMng.OnIntentRecognitionSucceededEvent += IntentRecognitionSucceededEventHandler;
_speechMng.OnUserSpeechInputStartedEvent += UserSpeechInputStartedEventHandler; _speechMng.OnUserSpeechInputStartedEvent += UserSpeechInputStartedEventHandler;
_speechMng.OnIntentRecognitionFailedEvent += IntentRecognitionFailedEventHandler; _speechMng.OnIntentRecognitionFailedEvent += IntentRecognitionFailedEventHandler;
} }
private void IntentRecognitionInitiatedEventHandler(object sender, bool e)
{
_onIntentRecognitionInitiatedEventTriggered = true;
}
private void IntentRecognitionSucceededEventHandler(object sender, string intentID) private void IntentRecognitionSucceededEventHandler(object sender, string intentID)
{ {
_onIntentRecognitionSucceededEventTriggered = true; _onIntentRecognitionSucceededEventTriggered = true;
@ -650,19 +643,16 @@ public class BTC : MonoBehaviour {
[Task] [Task]
public void AddPossbileSpeechIntent(string intentID, string intentText) public void AddPossbileSpeechIntent(string intentID, string intentText)
{ {
switch (Task.getState) if (Task.getState == NodeState.FirstRun)
{ {
case NodeState.FirstRun: _requestDataModel.PossibleIntents.Add(intentID, intentText);
_requestDataModel.PossibleIntents.Add(intentID, intentText); foreach (var r in _requestDataModel.PossibleIntents)
foreach(var r in _requestDataModel.PossibleIntents) {
{ Debug.Log($"Possible Intent: {r.Key}, {r.Value}");
Debug.Log($"Possible Intent: {r.Key}, {r.Value}"); }
}
Task.SetSucceeded(); Task.SetSucceeded();
break; return;
case NodeState.Aborting:
break;
} }
} }
@ -758,6 +748,7 @@ public class BTC : MonoBehaviour {
if (Task.getState == NodeState.FirstRun) if (Task.getState == NodeState.FirstRun)
{ {
_requestDataModel.PossibleIntents.Clear(); _requestDataModel.PossibleIntents.Clear();
_recognizedIntentID = "";
Task.SetSucceeded(); Task.SetSucceeded();
return; return;
} }
@ -775,6 +766,11 @@ public class BTC : MonoBehaviour {
} }
#endregion #endregion
#region Speech Synthesizer
#endregion
#region Oculus Input #region Oculus Input
#if OCULUSVR_AVAILABLE #if OCULUSVR_AVAILABLE
[Task] [Task]

File diff suppressed because it is too large Load Diff