Add SetSpeechRecognitionLanguage and InitializeSpeechManager functions
parent
9806af358f
commit
eafeee13c5
|
@ -10,10 +10,14 @@
|
|||
|
||||
Tree("32_Grotto_Chatbot_Test") {
|
||||
Composite(Sequence) {
|
||||
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.InitializeSpeechManager()
|
||||
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.SetSpeechRecognitionLanguage("it-IT")
|
||||
//BTC.AddPossbileSpeechIntent("Story_B_Grotto.Nachfrage_Nonna_Grotto.2", "L’aiuto in cucina.")
|
||||
//BTC.AddPossbileSpeechIntent("Story_B_Grotto.Nachfrage_Nonna_Grotto.4", "Preferisco aspettarla nella sala del grotto. Non so cucinare.")
|
||||
|
||||
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.StartSpeechIntentRecognition()
|
||||
|
@ -29,7 +33,6 @@ Tree("32_Grotto_Chatbot_Test") {
|
|||
BTC.CompareUserSpeechInputStarted(false)
|
||||
BTC.StopSpeechIntentRecognition()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
|
||||
// Bilder Bergell
|
||||
//BTC.Run("LoadScene.NEXT.35Slideshow")
|
||||
|
@ -59,10 +62,9 @@ Tree("32_Grotto_Chatbot_Test_Compare_Intent") {
|
|||
|
||||
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.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
|
||||
BTC.UserStartedSpeechInput()
|
||||
|
@ -89,9 +91,10 @@ 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.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", "Tante grazie, è molto gentile da parte Sua (o altra risposta).")
|
||||
BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Kueche.2", "Vielen Dank, das ist nett (oder andere Antwort)")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
|
@ -102,14 +105,14 @@ Tree("Antwort_Nonna_Kueche") {
|
|||
BTC.SpeechIntentRecognized()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
// --- Outro ---
|
||||
BTC.GetKeyDown("Return")
|
||||
//BTC.GetKeyDown("Return")
|
||||
}
|
||||
|
||||
// Intent nicht erkannt
|
||||
Composite(Sequence) {
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
// --- Outro ---
|
||||
BTC.GetKeyDown("Return")
|
||||
//BTC.GetKeyDown("Return")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +122,7 @@ Tree("Antwort_Nonna_Kueche") {
|
|||
BTC.StopSpeechIntentRecognition()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
// --- Outro ---
|
||||
BTC.GetKeyDown("Return")
|
||||
//BTC.GetKeyDown("Return")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -128,9 +131,10 @@ Tree("Antwort_Nonna_Kueche") {
|
|||
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.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", "Sì, grazie, ho qualcosa con me (o un'altra risposta)")
|
||||
BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.2", "Ja, danke, ich habe etwas dabei (oder andere Antwort)")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
|
@ -162,9 +166,10 @@ Tree("Antwort_Nonna_Grotto_2") {
|
|||
Composite(Sequence) {
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
|
||||
BTC.SynthesizeText("Prima, viel Spass noch und dann guten Appetit!", "de-DE")
|
||||
BTC.SynthesizeText("Prima, viel Spass noch und dann guten Appetit!", "de-DE", "")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
//BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.6", "Grazie nonna, ciao!")
|
||||
BTC.AddPossbileSpeechIntent("Story_B_Grotto.Antwort_Nonna_Grotto.6", "Danke!")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
|
@ -174,13 +179,13 @@ Tree("Antwort_Nonna_Grotto_2") {
|
|||
BTC.UserStartedSpeechInput()
|
||||
BTC.SpeechIntentRecognized()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
//BTC.GetKeyDown("Return")
|
||||
}
|
||||
|
||||
// Intent nicht erkannt
|
||||
Composite(Sequence) {
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
//BTC.GetKeyDown("Return")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +194,7 @@ Tree("Antwort_Nonna_Grotto_2") {
|
|||
BTC.CompareUserSpeechInputStarted(false)
|
||||
BTC.StopSpeechIntentRecognition()
|
||||
BTC.ClearPossbileSpeechIntents()
|
||||
BTC.GetKeyDown("Return")
|
||||
//BTC.GetKeyDown("Return")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -619,22 +619,38 @@ public class BTC : MonoBehaviour {
|
|||
private bool _onSpeechOutputStartedEventTriggered = false;
|
||||
private bool _onSpeechOutputEndedEventTriggered = false;
|
||||
|
||||
private void OnEnable()
|
||||
void OnDisable()
|
||||
{
|
||||
_speechMng.OnIntentRecognitionSucceededEvent += IntentRecognitionSucceededEventHandler;
|
||||
_speechMng.OnUserSpeechInputStartedEvent += UserSpeechInputStartedEventHandler;
|
||||
_speechMng.OnIntentRecognitionFailedEvent += IntentRecognitionFailedEventHandler;
|
||||
_speechMng.OnSpeechOutputStartedEvent += SpeechOutputStartedEventHandler;
|
||||
_speechMng.OnSpeechOutputEndedEvent += SpeechOutputEndedEventHandler;
|
||||
UnsubscribeFromEvents();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
private void SubscribeToEvents()
|
||||
{
|
||||
_speechMng.OnIntentRecognitionSucceededEvent -= IntentRecognitionSucceededEventHandler;
|
||||
_speechMng.OnUserSpeechInputStartedEvent -= UserSpeechInputStartedEventHandler;
|
||||
_speechMng.OnIntentRecognitionFailedEvent -= IntentRecognitionFailedEventHandler;
|
||||
_speechMng.OnSpeechOutputStartedEvent -= SpeechOutputStartedEventHandler;
|
||||
_speechMng.OnSpeechOutputEndedEvent -= SpeechOutputEndedEventHandler;
|
||||
if (_speechMng != null)
|
||||
{
|
||||
// Speech Intent Recognizer Events
|
||||
_speechMng.OnUserSpeechInputStartedEvent += UserSpeechInputStartedEventHandler;
|
||||
_speechMng.OnIntentRecognitionSucceededEvent += IntentRecognitionSucceededEventHandler;
|
||||
_speechMng.OnIntentRecognitionFailedEvent += IntentRecognitionFailedEventHandler;
|
||||
|
||||
// Speech Output Events
|
||||
_speechMng.OnSpeechOutputStartedEvent += SpeechOutputStartedEventHandler;
|
||||
_speechMng.OnSpeechOutputEndedEvent += SpeechOutputEndedEventHandler;
|
||||
|
||||
Debug.Log("SubscribeToEvents successfull.");
|
||||
}
|
||||
}
|
||||
|
||||
private void UnsubscribeFromEvents()
|
||||
{
|
||||
if (_speechMng != null)
|
||||
{
|
||||
_speechMng.OnIntentRecognitionSucceededEvent -= IntentRecognitionSucceededEventHandler;
|
||||
_speechMng.OnUserSpeechInputStartedEvent -= UserSpeechInputStartedEventHandler;
|
||||
_speechMng.OnIntentRecognitionFailedEvent -= IntentRecognitionFailedEventHandler;
|
||||
_speechMng.OnSpeechOutputStartedEvent -= SpeechOutputStartedEventHandler;
|
||||
_speechMng.OnSpeechOutputEndedEvent -= SpeechOutputEndedEventHandler;
|
||||
}
|
||||
}
|
||||
|
||||
private void IntentRecognitionSucceededEventHandler(object sender, string intentID)
|
||||
|
@ -663,6 +679,22 @@ public class BTC : MonoBehaviour {
|
|||
_onSpeechOutputEndedEventTriggered = true;
|
||||
}
|
||||
|
||||
[Task]
|
||||
public async void InitializeSpeechManager()
|
||||
{
|
||||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
while (_speechMng == null)
|
||||
{
|
||||
await System.Threading.Tasks.Task.Delay(10);
|
||||
}
|
||||
|
||||
SubscribeToEvents();
|
||||
Task.SetSucceeded();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[Task]
|
||||
public void AddPossbileSpeechIntent(string intentID, string intentText)
|
||||
{
|
||||
|
@ -787,15 +819,36 @@ public class BTC : MonoBehaviour {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Task]
|
||||
public void SynthesizeText(string text, string languageCode)
|
||||
public void SetSpeechRecognitionLanguage(string languageCode)
|
||||
{
|
||||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
_speechMng.SetSpeechRecognitionLanguage(languageCode);
|
||||
Debug.Log($"Set Speech Recognition Language to {languageCode}");
|
||||
Task.SetSucceeded();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[Task]
|
||||
public void SynthesizeText(string text, string languageCode, string voiceName)
|
||||
{
|
||||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
_onSpeechOutputStartedEventTriggered = false;
|
||||
_onSpeechOutputEndedEventTriggered = false;
|
||||
_speechMng.SynthesizeText(text, languageCode);
|
||||
|
||||
if (voiceName == "")
|
||||
{
|
||||
// Default Voice
|
||||
_speechMng.SynthesizeText(text, languageCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
_speechMng.SynthesizeText(text, languageCode, voiceName);
|
||||
}
|
||||
}
|
||||
|
||||
if (_onSpeechOutputStartedEventTriggered)
|
||||
|
@ -816,7 +869,6 @@ public class BTC : MonoBehaviour {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Oculus Input
|
||||
|
|
|
@ -1 +1 @@
|
|||
2024-09-13T12:37:02.1555720Z
|
||||
2024-09-18T14:25:36.7119300Z
|
File diff suppressed because it is too large
Load Diff
|
@ -140,6 +140,9 @@ PlayerSettings:
|
|||
bundleVersion: 0.1
|
||||
preloadedAssets:
|
||||
- {fileID: 11400000, guid: be340e3c48769439d8d18a5a2bccd498, type: 2}
|
||||
- {fileID: 11400000, guid: bfa1182bd221b4ca89619141f66f1260, type: 2}
|
||||
- {fileID: -8196854396901781169, guid: 1a4c68ca72a83449f938d669337cb305, type: 2}
|
||||
- {fileID: -64324148185763206, guid: a9a6963505ddf7f4d886008c6dc86122, type: 2}
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
m_HolographicPauseOnTrackingLoss: 1
|
||||
|
|
Loading…
Reference in New Issue