Speech Output Functions for BT
parent
e6d0accd34
commit
9806af358f
|
@ -10,7 +10,9 @@
|
|||
|
||||
Tree("32_Grotto_Chatbot_Test") {
|
||||
Composite(Sequence) {
|
||||
BTC.GetKeyDown("Return") // Nonna zeile 370
|
||||
BTC.GetKeyDown("Return")
|
||||
BTC.SynthesizeText("Ich möchte nirgends sonst auf der Welt leben. Möchtest du denn mit Francesca in der Küche etwas aushelfen oder wartest du im Garten auf sie?", "de-DE")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
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.")
|
||||
|
@ -27,6 +29,7 @@ Tree("32_Grotto_Chatbot_Test") {
|
|||
BTC.CompareUserSpeechInputStarted(false)
|
||||
BTC.StopSpeechIntentRecognition()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
|
||||
// Bilder Bergell
|
||||
//BTC.Run("LoadScene.NEXT.35Slideshow")
|
||||
|
@ -45,21 +48,20 @@ Tree("32_Grotto_Chatbot_Test_Compare_Intent") {
|
|||
Composite(Race) {
|
||||
Composite(Sequence) {
|
||||
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
// ...
|
||||
RunTree("Antwort_Nonna_Kueche")
|
||||
}
|
||||
Composite(Sequence) {
|
||||
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
// ...
|
||||
RunTree("Antwort_Nonna_Grotto")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Composite(Sequence) {
|
||||
// SpeechIntentRecognized Failed: kein Intent erkannt
|
||||
BTC.SynthesizeText("Was wolltest du sagen? Ich habe es nicht verstanden. Möchtest du mithelfen oder lieber im Garten warten?", "de-DE")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
BTC.GetKeyDown("Tab")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
// Fallback fehlt, wenn nichts gesagt wird
|
||||
|
@ -69,15 +71,11 @@ Tree("32_Grotto_Chatbot_Test_Compare_Intent") {
|
|||
Composite(Race) {
|
||||
Composite(Sequence) {
|
||||
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.2")
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
// ...
|
||||
RunTree("Antwort_Nonna_Kueche")
|
||||
}
|
||||
Composite(Sequence) {
|
||||
BTC.CompareIntentID("Story_B_Grotto.Nachfrage_Nonna_Grotto.4")
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
// ...
|
||||
RunTree("Antwort_Nonna_Grotto")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +86,115 @@ Tree("32_Grotto_Chatbot_Test_Compare_Intent") {
|
|||
}
|
||||
}
|
||||
|
||||
Tree("Antwort_Nonna_Kueche") {
|
||||
Composite(Sequence) {
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.SynthesizeText("Oh, das ist wunderbar, vielen Dank! Anschliessend seid ihr selbstverständlich zum Essen eingeladen.", "de-DE")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Kueche.2", "Vielen Dank, das ist nett (oder andere Antwort)")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
Composite(Race) {
|
||||
Composite(Selector) {
|
||||
Composite(Sequence) {
|
||||
BTC.UserStartedSpeechInput()
|
||||
BTC.SpeechIntentRecognized()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
// --- Outro ---
|
||||
BTC.GetKeyDown("Return")
|
||||
}
|
||||
|
||||
// Intent nicht erkannt
|
||||
Composite(Sequence) {
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
// --- Outro ---
|
||||
BTC.GetKeyDown("Return")
|
||||
}
|
||||
}
|
||||
|
||||
Composite(Sequence) {
|
||||
BTC.Wait(5)
|
||||
BTC.CompareUserSpeechInputStarted(false)
|
||||
BTC.StopSpeechIntentRecognition()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
// --- Outro ---
|
||||
BTC.GetKeyDown("Return")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tree("Antwort_Nonna_Grotto") {
|
||||
Composite(Sequence) {
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.SynthesizeText("Okay gut, mach es dir gemütlich. Hast du etwas zum Lesen dabei?", "de-DE")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.2", "Ja, danke, ich habe etwas dabei (oder andere Antwort)")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
Composite(Race) {
|
||||
Composite(Selector) {
|
||||
Composite(Sequence) {
|
||||
BTC.UserStartedSpeechInput()
|
||||
BTC.SpeechIntentRecognized()
|
||||
RunTree("Antwort_Nonna_Grotto_2")
|
||||
}
|
||||
|
||||
// Intent nicht erkannt
|
||||
Composite(Sequence) {
|
||||
RunTree("Antwort_Nonna_Grotto_2")
|
||||
}
|
||||
}
|
||||
|
||||
Composite(Sequence) {
|
||||
BTC.Wait(5)
|
||||
BTC.CompareUserSpeechInputStarted(false)
|
||||
BTC.StopSpeechIntentRecognition()
|
||||
RunTree("Antwort_Nonna_Grotto_2")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tree("Antwort_Nonna_Grotto_2") {
|
||||
Composite(Sequence) {
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
|
||||
BTC.SynthesizeText("Prima, viel Spass noch und dann guten Appetit!", "de-DE")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.6", "Danke!")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
Composite(Race) {
|
||||
Composite(Selector) {
|
||||
Composite(Sequence) {
|
||||
BTC.UserStartedSpeechInput()
|
||||
BTC.SpeechIntentRecognized()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
}
|
||||
|
||||
// Intent nicht erkannt
|
||||
Composite(Sequence) {
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
}
|
||||
}
|
||||
|
||||
Composite(Sequence) {
|
||||
BTC.Wait(5)
|
||||
BTC.CompareUserSpeechInputStarted(false)
|
||||
BTC.StopSpeechIntentRecognition()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tree("32_Grotto_Kueche_Intro") {
|
||||
Composite(Sequence) {
|
||||
BTC.Run("AudioSource.AUDIO.Kueche1FIntro")
|
||||
|
|
|
@ -609,19 +609,32 @@ public class BTC : MonoBehaviour {
|
|||
#endif
|
||||
#endregion
|
||||
|
||||
#region Speech Intent Recognizer
|
||||
#region Speech Intent Recognizer and Speech Synthesizer
|
||||
private ViaggioAIManager _speechMng { get { return ViaggioAIManager.Instance; } }
|
||||
private RequestDataModel _requestDataModel = new RequestDataModel();
|
||||
private string _recognizedIntentID = "";
|
||||
private bool _onIntentRecognitionSucceededEventTriggered = false;
|
||||
private bool _onUserSpeechInputStartedEventTriggered = false;
|
||||
private bool _onIntentRecognitionFailedEventTriggered = false;
|
||||
private bool _onSpeechOutputStartedEventTriggered = false;
|
||||
private bool _onSpeechOutputEndedEventTriggered = false;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_speechMng.OnIntentRecognitionSucceededEvent += IntentRecognitionSucceededEventHandler;
|
||||
_speechMng.OnUserSpeechInputStartedEvent += UserSpeechInputStartedEventHandler;
|
||||
_speechMng.OnIntentRecognitionFailedEvent += IntentRecognitionFailedEventHandler;
|
||||
_speechMng.OnSpeechOutputStartedEvent += SpeechOutputStartedEventHandler;
|
||||
_speechMng.OnSpeechOutputEndedEvent += SpeechOutputEndedEventHandler;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_speechMng.OnIntentRecognitionSucceededEvent -= IntentRecognitionSucceededEventHandler;
|
||||
_speechMng.OnUserSpeechInputStartedEvent -= UserSpeechInputStartedEventHandler;
|
||||
_speechMng.OnIntentRecognitionFailedEvent -= IntentRecognitionFailedEventHandler;
|
||||
_speechMng.OnSpeechOutputStartedEvent -= SpeechOutputStartedEventHandler;
|
||||
_speechMng.OnSpeechOutputEndedEvent -= SpeechOutputEndedEventHandler;
|
||||
}
|
||||
|
||||
private void IntentRecognitionSucceededEventHandler(object sender, string intentID)
|
||||
|
@ -640,6 +653,16 @@ public class BTC : MonoBehaviour {
|
|||
_onIntentRecognitionFailedEventTriggered = true;
|
||||
}
|
||||
|
||||
private void SpeechOutputStartedEventHandler(object sender, bool e)
|
||||
{
|
||||
_onSpeechOutputStartedEventTriggered = true;
|
||||
}
|
||||
|
||||
private void SpeechOutputEndedEventHandler(object sender, bool e)
|
||||
{
|
||||
_onSpeechOutputEndedEventTriggered = true;
|
||||
}
|
||||
|
||||
[Task]
|
||||
public void AddPossbileSpeechIntent(string intentID, string intentText)
|
||||
{
|
||||
|
@ -725,7 +748,7 @@ public class BTC : MonoBehaviour {
|
|||
[Task]
|
||||
public void CompareIntentID(string intentID)
|
||||
{
|
||||
if ((Task.getState == NodeState.FirstRun))
|
||||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
if (_recognizedIntentID == intentID)
|
||||
{
|
||||
|
@ -764,10 +787,35 @@ public class BTC : MonoBehaviour {
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Task]
|
||||
public void SynthesizeText(string text, string languageCode)
|
||||
{
|
||||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
_onSpeechOutputStartedEventTriggered = false;
|
||||
_onSpeechOutputEndedEventTriggered = false;
|
||||
_speechMng.SynthesizeText(text, languageCode);
|
||||
}
|
||||
|
||||
#region Speech Synthesizer
|
||||
if (_onSpeechOutputStartedEventTriggered)
|
||||
{
|
||||
Debug.Log("SynthesizeText: Speech Output started.");
|
||||
Task.SetSucceeded();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[Task]
|
||||
public void SpeechOutputEnded()
|
||||
{
|
||||
if (_onSpeechOutputEndedEventTriggered)
|
||||
{
|
||||
Debug.Log("SynthesizeText: Speech Output ended.");
|
||||
Task.SetSucceeded();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue