From 4ca252568eabc5863aac951be541a77ef59456e9 Mon Sep 17 00:00:00 2001 From: Nadine Ganz Date: Mon, 3 Feb 2025 17:40:54 +0100 Subject: [PATCH] Implementing story B kueche --- .../Assets/BehaviourTrees/3.2-Grotto.bt.txt | 89 ++++++++++++++----- .../Assets/Scripts/Speech/LoadSpeechData.cs | 4 +- .../Speech/viaggioSpeechIntents_it.json | 13 +-- 3 files changed, 74 insertions(+), 32 deletions(-) diff --git a/Viagg-io/Assets/BehaviourTrees/3.2-Grotto.bt.txt b/Viagg-io/Assets/BehaviourTrees/3.2-Grotto.bt.txt index a7f8e86..226d256 100644 --- a/Viagg-io/Assets/BehaviourTrees/3.2-Grotto.bt.txt +++ b/Viagg-io/Assets/BehaviourTrees/3.2-Grotto.bt.txt @@ -14,11 +14,13 @@ Composite(Sequence) { //RunTree("32_Grotto_Story_B_Grotto_Intro") - RunTree("32_Grotto_Kueche_Intro") + //RunTree("32_Grotto_Kueche_Intro") //RunTree("32_Grotto_Kueche_Zwiebeln_schneiden") //RunTree("32_Grotto_Kueche_alles_gefunden") + //RunTree("32_Grotto_Kueche_Interesse_Kochen") //RunTree("32_Grotto_Kueche_Kochen_Anzahl") //RunTree("32_Grotto_Kueche_Zusammen_Kochen") + RunTree("32_Grotto_Kueche_Parmigiano") //RunTree("32_Grotto_Im_Grotto_Essen_Intro") } } @@ -924,28 +926,43 @@ Tree("32_Grotto_Kueche_Interesse_Kochen") { // --- Kueche - Interesse Kochen --- Composite(Sequence) { BTC.Run("AudioSource.AUDIO.Kueche1InteresseKo") - // ToDo: Freie Antwort als Speech Input - BTC.Set("TextMeshPro.GO.Option1Button", "text", "Lasagne") - BTC.Show("GO.GO.Option1Button") - BTC.SetBool("32_Grotto_Kueche_Interesse_Kochen_Button_Clicked", false) + // Frage beantworten + BTC.AddPossbileSpeechIntent("Kueche.Interesse_Kochen.2") + BTC.StartSpeechIntentRecognition() Composite(Race) { + // -- Race 1: User sagt etwas Composite(Sequence) { - // Lieblingsessen nennen - BTC.Run("NamedEventTrigger.GO.Option1Button") - BTC.SetBool("32_Grotto_Kueche_Interesse_Kochen_Button_Clicked") - BTC.Hide("GO.GO.Option1Button") - RunTree("32_Grotto_Kueche_Kochen_Anzahl") + BTC.UserStartedSpeechInput() + + Composite(Selector) { + // -- Selector 1: Intent erkannt + Composite(Sequence) { + BTC.SpeechIntentRecognized() + + // Intent erkannt + BTC.ClearPossbileSpeechIntents() + RunTree("32_Grotto_Kueche_Kochen_Anzahl") + } + + // -- Selector 2: Intent nicht erkannt + Composite(Sequence) { + BTC.ClearPossbileSpeechIntents() + RunTree("32_Grotto_Kueche_Kochen_Anzahl") + } + } } + + // -- Race 2: User sagt nichts Composite(Sequence) { - // keine Antwort BTC.Wait(5) - BTC.CompareBool("32_Grotto_Kueche_Interesse_Kochen_Button_Clicked", false) - BTC.AbortEventListener("NamedEventTrigger.GO.Option1Button") - BTC.Hide("GO.GO.Option1Button") + BTC.CompareUserSpeechInputStarted(false) + BTC.AbortSpeechEventListener() + BTC.StopSpeechIntentRecognition() + BTC.ClearPossbileSpeechIntents() RunTree("32_Grotto_Kueche_Zusammen_Kochen") } - } + } } } @@ -1108,26 +1125,50 @@ Tree("32_Grotto_Kueche_Selbststaendig_Kochen") { Tree("32_Grotto_Kueche_Parmigiano") { // --- Kueche - Parmigiano --- Composite(Sequence) { - BTC.SynthesizeText("Schau, ich habe dir den Parmigiano hingestellt. Du kannst ihn nun in den Topf geben.") + BTC.SynthesizeText("Ho preparato il parmigiano, puoi aggiungerlo al risotto, per piacere?") BTC.SpeechOutputEnded() // Parmigiano in Topf geben - BTC.Run("NamedGrabEvent.INTERACTABLES.Parmigiano") BTC.Set("Collider.INTERACTABLES.Topf", "otherTag", "Parmigiano") BTC.Run("Collider.INTERACTABLES.Topf") - BTC.SynthesizeText("Bist du fertig?") + BTC.SynthesizeText("Hai finito?") BTC.SpeechOutputEnded() // Antwort User - // ToDo: Sprache fehlt - BTC.Set("TextMeshPro.GO.Option1Button", "text", "Ja") - BTC.Show("GO.GO.Option1Button") + BTC.AddPossbileSpeechIntent("Kueche.Zusammen_Kochen.6") + BTC.StartSpeechIntentRecognition() + Composite(Race) { - BTC.Run("NamedEventTrigger.GO.Option1Button") - BTC.Wait(5) + // -- Race 1: User sagt etwas + Composite(Sequence) { + BTC.UserStartedSpeechInput() + + Composite(Selector) { + // -- Selector 1: Intent erkannt + Composite(Sequence) { + BTC.SpeechIntentRecognized() + + // Intent erkannt + BTC.ClearPossbileSpeechIntents() + } + + // -- Selector 2: Intent nicht erkannt + Composite(Sequence) { + BTC.ClearPossbileSpeechIntents() + } + } + } + + // -- Race 2: User sagt nichts + Composite(Sequence) { + BTC.Wait(5) + BTC.CompareUserSpeechInputStarted(false) + BTC.AbortSpeechEventListener() + BTC.StopSpeechIntentRecognition() + BTC.ClearPossbileSpeechIntents() + } } - BTC.Hide("GO.GO.Option1Button") BTC.SynthesizeText("Bitte stelle den Risotto hier hin.") BTC.SpeechOutputEnded() diff --git a/Viagg-io/Assets/Scripts/Speech/LoadSpeechData.cs b/Viagg-io/Assets/Scripts/Speech/LoadSpeechData.cs index 1d7cf3c..8ccda8e 100644 --- a/Viagg-io/Assets/Scripts/Speech/LoadSpeechData.cs +++ b/Viagg-io/Assets/Scripts/Speech/LoadSpeechData.cs @@ -22,12 +22,12 @@ public class LoadSpeechData : MonoBehaviour foreach (IntentData _obj in _intentList.intents) { - Debug.Log($"IntentID: {_obj.intentID}, Sentences Count: {_obj.intentSentences.Count}"); + //Debug.Log($"IntentID: {_obj.intentID}, Sentences Count: {_obj.intentSentences.Count}"); string _combinedSentences = string.Join(", ", _obj.intentSentences); _dicIntents.Add(_obj.intentID, _combinedSentences); - Debug.Log($"Added {_combinedSentences} to {_obj.intentID}"); + //Debug.Log($"Added {_combinedSentences} to {_obj.intentID}"); } SpeechData.intents = _dicIntents; diff --git a/Viagg-io/Assets/Scripts/Speech/viaggioSpeechIntents_it.json b/Viagg-io/Assets/Scripts/Speech/viaggioSpeechIntents_it.json index f2f0980..fce31c1 100644 --- a/Viagg-io/Assets/Scripts/Speech/viaggioSpeechIntents_it.json +++ b/Viagg-io/Assets/Scripts/Speech/viaggioSpeechIntents_it.json @@ -173,12 +173,7 @@ "intentID": "Kueche.Interesse_Kochen.2", "intentSentences": [ "Mi piace fare la pizza.", - "Mi piace fare torte o biscotti al forno." - ] - }, - { - "intentID": "Kueche.Interesse_Kochen.4", - "intentSentences": [ + "Mi piace fare torte o biscotti al forno.", "Mi piace fare la pasta.", "Cucino con la mamma." ] @@ -199,6 +194,12 @@ "No, non cucino mai." ] }, + { + "intentID": "Kueche.Zusammen_Kochen.6", + "intentSentences": [ + "S\u00ec." + ] + }, { "intentID": "Kueche.Outro.4", "intentSentences": [