Handling multiple sentences for one Intent ID; add json with intents
parent
e307804713
commit
1930966955
|
@ -2,12 +2,12 @@
|
|||
Composite(Sequence) {
|
||||
BTC.InitializeSpeechManager()
|
||||
// BTC.Wait(30) oder Button Klick
|
||||
BTC.SynthesizeText("Wir beiden werden jetzt ein feines Risotto nach dem Rezept meiner Nonna kochen. Kochst du denn gerne?", "de-DE", "")
|
||||
BTC.SynthesizeText("Wir beide werden jetzt ein feines Risotto nach dem Rezept meiner Nonna kochen. Kochst du denn gerne?")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
// Frage beantworten
|
||||
BTC.AddPossbileSpeechIntent("Kueche.alles_gefunden.4", "Ja., Ja, ich koche gerne., Ich koche gerne., Ich liebe es zu kochen., Ja, sehr gerne.")
|
||||
BTC.AddPossbileSpeechIntent("Kueche.alles_gefunden.6", "Nein., Nein, ich koche nicht gerne., Ich mag Kochen nicht., Nein, gar nicht.")
|
||||
BTC.AddPossbileSpeechIntent("Kueche.alles_gefunden.4")
|
||||
BTC.AddPossbileSpeechIntent("Kueche.alles_gefunden.6")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
Composite(Race) {
|
||||
|
@ -111,11 +111,11 @@
|
|||
Tree("32_Grotto_Kueche_Interesse_Kochen") {
|
||||
// --- Kueche - Interesse Kochen ---
|
||||
Composite(Sequence) {
|
||||
BTC.SynthesizeText("Was kochst du denn manchmal so?", "de-DE", "")
|
||||
BTC.SynthesizeText("Was kochst du denn manchmal so?")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
// Frage beantworten
|
||||
BTC.AddPossbileSpeechIntent("Kueche.Interesse_Kochen.2", "Ich koche gerne xy., Ich mache gerne xy.")
|
||||
BTC.AddPossbileSpeechIntent("Kueche.Interesse_Kochen.2")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
Composite(Race) {
|
||||
|
@ -154,12 +154,12 @@ Tree("32_Grotto_Kueche_Interesse_Kochen") {
|
|||
Tree("32_Grotto_Kueche_Kochen_Anzahl") {
|
||||
// --- Kueche - Kochen Anzahl ---
|
||||
Composite(Sequence) {
|
||||
BTC.SynthesizeText("Ja, das mag ich auch gerne. Wie oft kochst du denn so?", "de-DE", "")
|
||||
BTC.SynthesizeText("Ja, das mag ich auch gerne. Wie oft kochst du denn so?")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
// Frage beantworten
|
||||
BTC.AddPossbileSpeechIntent("Kueche.Kochen_Anzahl.2", "Sehr oft., Fast täglich., Jeden Tag., Nur am Wochenende., Unter der Woche.")
|
||||
BTC.AddPossbileSpeechIntent("Kueche.Kochen_Anzahl.4", "Fast nie., Selten.")
|
||||
BTC.AddPossbileSpeechIntent("Kueche.Kochen_Anzahl.2")
|
||||
BTC.AddPossbileSpeechIntent("Kueche.Kochen_Anzahl.4")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
Composite(Race) {
|
||||
|
@ -198,11 +198,11 @@ Tree("32_Grotto_Kueche_Kochen_Anzahl") {
|
|||
Tree("32_Grotto_Kueche_Desinteresse_Kochen") {
|
||||
// --- Kueche - Desinteresse Kochen ---
|
||||
Composite(Sequence) {
|
||||
BTC.SynthesizeText("Oh okay, aber heute kochen wir gemeinsam und das Risotto ist auch nicht allzu schwer. Was ist denn dein Lieblingsgericht? ", "de-DE", "")
|
||||
BTC.SynthesizeText("Oh okay, aber heute kochen wir gemeinsam und das Risotto ist auch nicht allzu schwer. Was ist denn dein Lieblingsgericht?")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
// Lieblingsgericht beantworten
|
||||
BTC.AddPossbileSpeechIntent("Kueche.Desinteresse_Kochen.2", "Ich esse gerne xy., Ich liebe xy., Ich mag xy., (oder andere Antwort)")
|
||||
BTC.AddPossbileSpeechIntent("Kueche.Desinteresse_Kochen.2")
|
||||
BTC.StartSpeechIntentRecognition()
|
||||
|
||||
Composite(Race) {
|
||||
|
@ -234,7 +234,7 @@ Tree("32_Grotto_Kueche_Desinteresse_Kochen") {
|
|||
}
|
||||
}
|
||||
|
||||
BTC.SynthesizeText("Ja, das mag ich auch gerne.", "de-DE", "")
|
||||
BTC.SynthesizeText("Ja, das mag ich auch gerne.")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
RunTree("32_Grotto_Kueche_Interaktion")
|
||||
|
@ -243,7 +243,7 @@ Tree("32_Grotto_Kueche_Desinteresse_Kochen") {
|
|||
|
||||
Tree("32_Grotto_Kueche_Interaktion") {
|
||||
Composite(Sequence) {
|
||||
BTC.SynthesizeText("Gut, dann fangen wir jetzt mit dem Risotto an. Schütte bitte die Zwiebeln und den Reis in den Topf.", "de-DE", "")
|
||||
BTC.SynthesizeText("Gut, dann fangen wir jetzt mit dem Risotto an. Schütte bitte die Zwiebeln und den Reis in den Topf.")
|
||||
BTC.SpeechOutputEnded()
|
||||
|
||||
BTC.GetKeyDown("Return")
|
||||
|
|
|
@ -721,11 +721,11 @@ public class BTC : MonoBehaviour {
|
|||
}
|
||||
|
||||
[Task]
|
||||
public void AddPossbileSpeechIntent(string intentID, string intentText)
|
||||
public void AddPossbileSpeechIntent(string id)
|
||||
{
|
||||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
_requestDataModel.PossibleIntents.Add(intentID, intentText);
|
||||
_requestDataModel.PossibleIntents.Add(id, SpeechData.intents[id]);
|
||||
foreach (var r in _requestDataModel.PossibleIntents)
|
||||
{
|
||||
Debug.Log($"Possible Intent: {r.Key}, {r.Value}");
|
||||
|
@ -871,6 +871,7 @@ public class BTC : MonoBehaviour {
|
|||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
_speechMng.SetSpeechRecognitionLanguage(languageCode);
|
||||
SpeechData.languageCode = languageCode;
|
||||
Debug.Log($"Set Speech Recognition Language to {languageCode}");
|
||||
Task.SetSucceeded();
|
||||
return;
|
||||
|
@ -878,22 +879,26 @@ public class BTC : MonoBehaviour {
|
|||
}
|
||||
|
||||
[Task]
|
||||
public void SynthesizeText(string text, string languageCode, string voiceName)
|
||||
public void SetVoiceName(string voiceName)
|
||||
{
|
||||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
SpeechData.voiceName = voiceName;
|
||||
Debug.Log($"Set VoiceName to {voiceName}");
|
||||
Task.SetSucceeded();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[Task]
|
||||
public void SynthesizeText(string text)
|
||||
{
|
||||
if (Task.getState == NodeState.FirstRun)
|
||||
{
|
||||
_onSpeechOutputStartedEventTriggered = false;
|
||||
_onSpeechOutputEndedEventTriggered = false;
|
||||
|
||||
if (voiceName == "")
|
||||
{
|
||||
// Default Voice
|
||||
_speechMng.SynthesizeText(text, languageCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
_speechMng.SynthesizeText(text, languageCode, voiceName);
|
||||
}
|
||||
_speechMng.SynthesizeText(text, SpeechData.languageCode, SpeechData.voiceName);
|
||||
}
|
||||
|
||||
if (_onSpeechOutputStartedEventTriggered)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f4aa1199bf4e142d59f042c5115447a7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,29 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LoadSpeechData : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
TextAsset intentJson;
|
||||
|
||||
private Dictionary<string, string> _dicIntents = new Dictionary<string, string>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
IntentList _intentList = JsonUtility.FromJson<IntentList>(intentJson.text);
|
||||
|
||||
foreach (IntentData _obj in _intentList.intents)
|
||||
{
|
||||
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}");
|
||||
}
|
||||
|
||||
SpeechData.intents = _dicIntents;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3766f95ede233404dbe8045cd127dfff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,23 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class SpeechData
|
||||
{
|
||||
public static string languageCode = "de-DE";
|
||||
public static string voiceName = "de-DE-KatjaNeural";
|
||||
public static Dictionary<string, string> intents = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class IntentData
|
||||
{
|
||||
public string intentID;
|
||||
public List<string> intentSentences;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class IntentList
|
||||
{
|
||||
public List<IntentData> intents;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7337603aaaa0a48398c1ddeaa78e5e90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"intents": [
|
||||
{
|
||||
"intentID": "Kueche.alles_gefunden.4",
|
||||
"intentSentences": [
|
||||
"Ja.",
|
||||
"Ja, ich koche gerne.",
|
||||
"Ich koche gerne.",
|
||||
"Ich liebe es zu kochen.",
|
||||
"Ja, sehr gerne."
|
||||
]
|
||||
},
|
||||
{
|
||||
"intentID": "Kueche.alles_gefunden.6",
|
||||
"intentSentences": [
|
||||
"Nein.",
|
||||
"Nein, ich koche nicht gerne.",
|
||||
"Ich mag Kochen nicht.",
|
||||
"Nein, gar nicht."
|
||||
]
|
||||
},
|
||||
{
|
||||
"intentID": "Kueche.Interesse_Kochen.2",
|
||||
"intentSentences": [
|
||||
"Ich koche gerne xy.",
|
||||
"Ich mache gerne xy."
|
||||
]
|
||||
},
|
||||
{
|
||||
"intentID": "Kueche.Kochen_Anzahl.2",
|
||||
"intentSentences": [
|
||||
"Sehr oft.",
|
||||
"Fast t\u00e4glich.",
|
||||
"Jeden Tag."
|
||||
]
|
||||
},
|
||||
{
|
||||
"intentID": "Kueche.Kochen_Anzahl.4",
|
||||
"intentSentences": [
|
||||
"Fast nie.",
|
||||
"Selten.",
|
||||
"Sporadisch.",
|
||||
"Nur am Wochenende."
|
||||
]
|
||||
},
|
||||
{
|
||||
"intentID": "Kueche.Desinteresse_Kochen.2",
|
||||
"intentSentences": [
|
||||
"Ich esse gerne xy.",
|
||||
"Ich liebe xy.",
|
||||
"Ich mag xy."
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3f0b8c9e9c318472293e169f2a5aa33b
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue