Speech Output Functions for BT
parent
e6d0accd34
commit
9806af358f
|
@ -10,7 +10,9 @@
|
||||||
|
|
||||||
Tree("32_Grotto_Chatbot_Test") {
|
Tree("32_Grotto_Chatbot_Test") {
|
||||||
Composite(Sequence) {
|
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.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.")
|
||||||
|
@ -27,6 +29,7 @@ Tree("32_Grotto_Chatbot_Test") {
|
||||||
BTC.CompareUserSpeechInputStarted(false)
|
BTC.CompareUserSpeechInputStarted(false)
|
||||||
BTC.StopSpeechIntentRecognition()
|
BTC.StopSpeechIntentRecognition()
|
||||||
BTC.ClearPossbileSpeechIntents()
|
BTC.ClearPossbileSpeechIntents()
|
||||||
|
BTC.GetKeyDown("Return")
|
||||||
|
|
||||||
// Bilder Bergell
|
// Bilder Bergell
|
||||||
//BTC.Run("LoadScene.NEXT.35Slideshow")
|
//BTC.Run("LoadScene.NEXT.35Slideshow")
|
||||||
|
@ -45,21 +48,20 @@ 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()
|
RunTree("Antwort_Nonna_Kueche")
|
||||||
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()
|
RunTree("Antwort_Nonna_Grotto")
|
||||||
BTC.GetKeyDown("Return")
|
|
||||||
// ...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Composite(Sequence) {
|
Composite(Sequence) {
|
||||||
// SpeechIntentRecognized Failed: kein Intent erkannt
|
// 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.GetKeyDown("Tab")
|
||||||
BTC.StartSpeechIntentRecognition()
|
BTC.StartSpeechIntentRecognition()
|
||||||
// Fallback fehlt, wenn nichts gesagt wird
|
// Fallback fehlt, wenn nichts gesagt wird
|
||||||
|
@ -69,15 +71,11 @@ 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()
|
RunTree("Antwort_Nonna_Kueche")
|
||||||
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()
|
RunTree("Antwort_Nonna_Grotto")
|
||||||
BTC.GetKeyDown("Return")
|
|
||||||
// ...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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") {
|
Tree("32_Grotto_Kueche_Intro") {
|
||||||
Composite(Sequence) {
|
Composite(Sequence) {
|
||||||
BTC.Run("AudioSource.AUDIO.Kueche1FIntro")
|
BTC.Run("AudioSource.AUDIO.Kueche1FIntro")
|
||||||
|
|
|
@ -609,19 +609,32 @@ public class BTC : MonoBehaviour {
|
||||||
#endif
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Speech Intent Recognizer
|
#region Speech Intent Recognizer and Speech Synthesizer
|
||||||
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 _onIntentRecognitionSucceededEventTriggered = false;
|
private bool _onIntentRecognitionSucceededEventTriggered = false;
|
||||||
private bool _onUserSpeechInputStartedEventTriggered = false;
|
private bool _onUserSpeechInputStartedEventTriggered = false;
|
||||||
private bool _onIntentRecognitionFailedEventTriggered = false;
|
private bool _onIntentRecognitionFailedEventTriggered = false;
|
||||||
|
private bool _onSpeechOutputStartedEventTriggered = false;
|
||||||
|
private bool _onSpeechOutputEndedEventTriggered = false;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
_speechMng.OnIntentRecognitionSucceededEvent += IntentRecognitionSucceededEventHandler;
|
_speechMng.OnIntentRecognitionSucceededEvent += IntentRecognitionSucceededEventHandler;
|
||||||
_speechMng.OnUserSpeechInputStartedEvent += UserSpeechInputStartedEventHandler;
|
_speechMng.OnUserSpeechInputStartedEvent += UserSpeechInputStartedEventHandler;
|
||||||
_speechMng.OnIntentRecognitionFailedEvent += IntentRecognitionFailedEventHandler;
|
_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)
|
private void IntentRecognitionSucceededEventHandler(object sender, string intentID)
|
||||||
|
@ -640,6 +653,16 @@ public class BTC : MonoBehaviour {
|
||||||
_onIntentRecognitionFailedEventTriggered = true;
|
_onIntentRecognitionFailedEventTriggered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SpeechOutputStartedEventHandler(object sender, bool e)
|
||||||
|
{
|
||||||
|
_onSpeechOutputStartedEventTriggered = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SpeechOutputEndedEventHandler(object sender, bool e)
|
||||||
|
{
|
||||||
|
_onSpeechOutputEndedEventTriggered = true;
|
||||||
|
}
|
||||||
|
|
||||||
[Task]
|
[Task]
|
||||||
public void AddPossbileSpeechIntent(string intentID, string intentText)
|
public void AddPossbileSpeechIntent(string intentID, string intentText)
|
||||||
{
|
{
|
||||||
|
@ -725,7 +748,7 @@ public class BTC : MonoBehaviour {
|
||||||
[Task]
|
[Task]
|
||||||
public void CompareIntentID(string intentID)
|
public void CompareIntentID(string intentID)
|
||||||
{
|
{
|
||||||
if ((Task.getState == NodeState.FirstRun))
|
if (Task.getState == NodeState.FirstRun)
|
||||||
{
|
{
|
||||||
if (_recognizedIntentID == intentID)
|
if (_recognizedIntentID == intentID)
|
||||||
{
|
{
|
||||||
|
@ -764,10 +787,35 @@ public class BTC : MonoBehaviour {
|
||||||
return;
|
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
|
#endregion
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue