SpeechInput Features for BT implemented

dev
Nadine Ganz 2024-09-17 14:18:12 +02:00
parent 25116cb8ff
commit 2a0e72ec07
3 changed files with 198961 additions and 161469 deletions

View File

@ -10,12 +10,81 @@
Tree("32_Grotto_Chatbot_Test") { Tree("32_Grotto_Chatbot_Test") {
Composite(Sequence) { Composite(Sequence) {
BTC.GetKeyDown("Return") // Nonna zeile 370
BTC.AddPossbileSpeechIntent("Story_B_Grotto.Nachfrage_Nonna_Grotto.2", "Ich helfe in der Küche.") BTC.AddPossbileSpeechIntent("Story_B_Grotto.Nachfrage_Nonna_Grotto.2", "Ich helfe in der Küche.")
BTC.AddPossbileSpeechIntent("Story_B_Grotto.Nachfrage_Nonna_Grotto.4", "Ich warte im Garten auf sie.") BTC.AddPossbileSpeechIntent("Story_B_Grotto.Nachfrage_Nonna_Grotto.4", "Ich warte im Garten auf sie.")
BTC.StartSpeechIntentRecognition() BTC.StartSpeechIntentRecognition()
BTC.SpeechIntentRecognized()
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2") Composite(Race) {
BTC.GetKeyDown("Return") Composite(Sequence) {
BTC.UserStartedSpeechInput()
RunTree("32_Grotto_Chatbot_Test_Compare_Intent")
}
Composite(Sequence) {
BTC.Wait(5)
BTC.CompareUserSpeechInputStarted(false)
RunTree("32_Grotto_Chatbot_Test_No_Answer")
}
}
}
}
Tree("32_Grotto_Chatbot_Test_Compare_Intent") {
Composite(Sequence) {
Composite(Selector) {
Composite(Sequence) {
BTC.SpeechIntentRecognized()
// Intent erkannt
Composite(Race) {
Composite(Sequence) {
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
BTC.GetKeyDown("Return")
// ...
}
Composite(Sequence) {
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
BTC.GetKeyDown("Return")
// ...
}
}
}
Composite(Sequence) {
// SpeechIntentRecognized Failed: kein Intent erkannt
BTC.GetKeyDown("Tab")
BTC.StartSpeechIntentRecognition()
// Fallback fehlt, wenn nichts gesagt wird
BTC.UserStartedSpeechInput()
BTC.SpeechIntentRecognized()
Composite(Race) {
Composite(Sequence) {
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
BTC.GetKeyDown("Return")
// ...
}
Composite(Sequence) {
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
BTC.GetKeyDown("Return")
// ...
}
}
}
// Fallback 2mal nicht verstanden: Button klick
}
}
}
Tree("32_Grotto_Chatbot_Test_No_Answer") {
Composite(Sequence) {
// Bilder Bergell
BTC.StopSpeechIntentRecognition()
//BTC.Run("LoadScene.NEXT.35Slideshow")
} }
} }

View File

@ -609,7 +609,7 @@ public class BTC : MonoBehaviour {
#endif #endif
#endregion #endregion
#region SpeechRecognicer #region SpeechRecognizer
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 = "";
@ -673,6 +673,18 @@ public class BTC : MonoBehaviour {
{ {
_onUserSpeechInputStartedEventTriggered = false; _onUserSpeechInputStartedEventTriggered = false;
_speechMng.StartIntentRecognition(_requestDataModel.PossibleIntents); _speechMng.StartIntentRecognition(_requestDataModel.PossibleIntents);
Task.SetSucceeded();
return;
}
}
[Task]
public void UserStartedSpeechInput()
{
if (Task.getState == NodeState.FirstRun)
{
_onIntentRecognitionSucceededEventTriggered = false;
_onIntentRecognitionFailedEventTriggered = false;
} }
if (_onUserSpeechInputStartedEventTriggered) if (_onUserSpeechInputStartedEventTriggered)
@ -685,12 +697,6 @@ public class BTC : MonoBehaviour {
[Task] [Task]
public void SpeechIntentRecognized() public void SpeechIntentRecognized()
{ {
if (Task.getState == NodeState.FirstRun)
{
_onIntentRecognitionSucceededEventTriggered = false;
_onIntentRecognitionFailedEventTriggered = false;
}
if (_onIntentRecognitionSucceededEventTriggered) if (_onIntentRecognitionSucceededEventTriggered)
{ {
Task.SetSucceeded(); Task.SetSucceeded();
@ -706,6 +712,26 @@ public class BTC : MonoBehaviour {
} }
} }
[Task]
public void CompareUserSpeechInputStarted(bool value)
{
if (Task.getState == NodeState.FirstRun)
{
if (_onUserSpeechInputStartedEventTriggered == value)
{
Debug.Log($"CompareUserSpeechInputStarted with {value} = equal");
Task.SetSucceeded();
return;
}
else
{
Debug.Log($"CompareUserSpeechInputStarted with {value} = not equal");
Task.SetFailed();
return;
}
}
}
[Task] [Task]
public void CompareIntentID(string intentID) public void CompareIntentID(string intentID)
{ {

File diff suppressed because it is too large Load Diff