IEnumerator GetMarket() { Debug.Log("Getting Market Data......."); UnityWebRequest www2 = UnityWebRequest.Get("https://eddb.io/archive/v5/listings.csv"); yield return(www2.SendWebRequest()); if (www2.isNetworkError || www2.isHttpError) { UnityEngine.Debug.Log(www2.error); } else { Debug.Log("Getting Market Data......."); SystemDump = www2.downloadHandler.text; string[] Marketdata = SystemDump.Split("\n"[0]); foreach (string line in Marketdata) { try { string[] Markets = line.Split(","[0]); EDDBMarkets.Add(new Markets { Commodity_id = Markets[2], Supply = Markets[3], buy_price = Markets[5], sell_price = Markets[6] }); } catch (Exception) { } } Debug.Log(EDDBMarkets[0].Commodity_id); } WindowsVoice.speak("Market Data Loaded", 0); }
private void Start() { WindowsVoice.speak("Welcome To The Remlok Intelligent H U D", 0); GetEDDB(); // GetFile(); InvokeRepeating("UpdateLists", 0, 1); }
IEnumerator GetCommodityList() { UnityWebRequest www2 = UnityWebRequest.Get("https://eddb.io/archive/v5/commodities.json"); yield return(www2.SendWebRequest()); if (www2.isNetworkError || www2.isHttpError) { UnityEngine.Debug.Log(www2.error); } else { SystemDump = www2.downloadHandler.text; string[] Marketdata = SystemDump.Split("}}"[0]); foreach (string line in Marketdata) { Debug.Log(line); try { Commodities eddbCommodity = JsonConvert.DeserializeObject <Commodities>(line); Debug.Log(line); EDDBCommodity.Add(new Commodities { name = eddbCommodity.name, id = eddbCommodity.id }); } catch (Exception) { } } } Debug.Log(EDDBCommodity.Count); WindowsVoice.speak("Commodity Data Loaded", 0); }
IEnumerator GetText() { UnityWebRequest www = UnityWebRequest.Get("https://eddb.io/archive/v5/systems_populated.jsonl"); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { UnityEngine.Debug.Log(www.error); } else { SystemDump = www.downloadHandler.text; string[] systemdata = SystemDump.Split("\n"[0]); foreach (string line in systemdata) { try { Systems eddb = JsonConvert.DeserializeObject <Systems>(line); EDDBData.Add(new Systems { name = eddb.name, x = eddb.x, y = eddb.y, z = eddb.z }); } catch (Exception) { } } } WindowsVoice.speak("Cartographic Data Loaded", 0); MissionCleanse(); WindowsVoice.speak("Mission System Online", 0); Debug.Log("System Data loaded"); }
public void SendText(string text) { ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; try { var response = apiAiUnity.TextRequest(text); if (response != null) { string outText = JsonConvert.SerializeObject(response); string targetBegin = "\"speech\":\""; string targetEnd = "\"},\"source\""; String result = getStringInBetween(outText, targetBegin, targetEnd); Debug.Log("Result: " + result); WindowsVoice.speak(result); } else { Debug.LogError("Response is null"); } } catch (Exception ex) { Debug.LogException(ex); } }
public void DeleteNavigationPoint(int navigationNumber) { if (sharedData.savedPlacesOnMap.Count > navigationNumber) { GameObject iconInstance = sharedData.savedPlacesOnMap[navigationNumber - 1]; //sharedData.savedPlacesOnMap.RemoveAt(navigationNumber - 1); sharedData.savedPlacesOnMap.Remove(iconInstance); Destroy(iconInstance); //Refresh der Nummerierung aller restlichen Orte int i = 1; foreach (GameObject otherIcon in sharedData.savedPlacesOnMap) { Text iconText = otherIcon.transform.Find("Image").Find("Text").GetComponent <Text>(); Debug.LogFormat("Nummer des Ortes war {0} bei Index {1}...", iconText.text, i); iconText.text = i.ToString(); Debug.LogFormat("...ist nun: {0}", iconText.text); i++; } //Löse Intent aus der NLU informiert, falls nun alle Orte entfernt wurden if (sharedData.savedPlacesOnMap.Count == 0) { EventManager.TriggerEvent(EventManager.asrRequerstDetectedEvent, new EventMessageObject(EventManager.asrRequerstDetectedEvent, "Alle gespeicherten Orte sind nun entfernt")); } } else { WindowsVoice.speak(string.Format("Ich konnte keinen Ort mit Nummer {0} finden.", navigationNumber), 3); } }
public void Speak(String _textToDisplay, Text _ausgabefeld = null) { if (_ausgabefeld != null) { DisplayText(_ausgabefeld, _textToDisplay); //nur solange keine TTS implementiert } WindowsVoice.speak(_textToDisplay); }
private void Start() { Factionpath = Application.dataPath + "/Resources/Factions.json"; MissionPath = Application.dataPath + "/Resources/missionlist.json"; WindowsVoice.speak("Welcome To The Remlok Intelligent H U D", 0); GetEDDB(); InvokeRepeating("UpdateLists", 0, 1f); }
// Update is called once per frame void Update() { time += Time.deltaTime; if (time >= T) { WindowsVoice.speak("Draw a " + word); } }
public void ProcessOutput(ApiAiSDK.Model.AIResponse res) { string outText = JsonConvert.SerializeObject(res); Debug.Log(outText); string result = res.Result.Fulfillment.Speech;//getStringInBetween(outText, targetBegin, targetEnd); Debug.Log("Result: " + result); WindowsVoice.speak(result); }
// Use this for initialization void Start() { m_Chat = new ChatData(); m_Chat.endPoint = m_Endpoints[0].endPoint; m_Chat.apiKey = m_Endpoints[0].apiKey; m_ConversationCanvas = GameObject.FindGameObjectWithTag("ConversationCanvas").gameObject; m_UserInput = m_ConversationCanvas.transform.Find("UserInput").transform.Find("Text Area").transform.Find("Text").gameObject.GetComponent <TMPro.TextMeshProUGUI>(); m_AvatarInput = m_ConversationCanvas.transform.Find("AvatarResponse").GetComponent <TMPro.TextMeshProUGUI>(); WindowsVoice.speak("リトルプラネットへようこそ"); }
public void OnPayChipClick() { if (Player == Game.theGame.CurrentPlayer) { if (Player.NumChips > 0) { Timeline.theTimeline.addEvent(new PPayChip()); } else { WindowsVoice.speak("Out of chips"); } } }
// Start is called before the first frame update void Start() { WindowsVoice.speak("こんにちは。写真を登録してください。"); retrievedHoroscope += OnRetrievedHoroscope; StartCoroutine(NetworkManager.GetRequest("http://api.jugemkey.jp/api/horoscope/free/2019/05/20", retrievedHoroscope)); m_WebcamManager = GameObject.FindGameObjectWithTag("CameraManager").GetComponent <WebcamManager>(); m_AzureManager = GameObject.FindGameObjectWithTag("AzureManager").GetComponent <AzureManager>(); m_BaseManager = GameObject.Find("BaseManager").GetComponent <BaseManager>(); m_ActivePersonGroup = GetPersonGroupId(); m_StatusText = GameObject.FindGameObjectWithTag("Status").GetComponent <TMPro.TextMeshProUGUI>(); m_GroupNameText = GameObject.FindGameObjectWithTag("GroupNameText").GetComponent <TMPro.TextMeshProUGUI>(); m_Endpoint = m_AzureManager.GetEndpoint(); m_ApiKey = m_AzureManager.GetApiKey(); m_CreatePersonButton = GameObject.FindGameObjectWithTag("CreatePersonButton").GetComponent <Button>(); m_CreatePersonButton.onClick.AddListener(() => { if (!m_CreatePersonButtonClicked) { string name = GetCurrentPersonName(); string birthday = GetCurrentPersonBirthday(); if (!name.Equals("null") && !birthday.Equals("null")) { Debug.Log("Checking if person Id exists..."); StartCoroutine(CheckPersonIdExists(name, birthday)); m_CreatePersonButtonClicked = true; } } }); m_AddFacesButton = GameObject.FindGameObjectWithTag("AddFacesButton").GetComponent <Button>(); m_AddFacesButton.onClick.AddListener(() => { // TODO : add body Debug.Log("Add faces body"); AddFacesToAzure(); }); }
IEnumerator DisplayCollectedItem(Text itemTextObj, string item) { audioSource.clip = itemSpellOutClip; foreach (var character in item) { itemTextObj.text += character; WindowsVoice.speak(character.ToString()); yield return(new WaitForSeconds(1.0f)); audioSource.Play(); yield return(new WaitForSeconds(1.0f)); } WindowsVoice.speak(itemTextObj.text); yield return(new WaitForSeconds(1.5f)); Destroy(itemTextObj); CharactersCanMove = true; }
private void Start() { MissionPath = Application.dataPath + "/Resources/missionlist.json"; WindowsVoice.speak("Welcome To The Remlok Intelligent H U D", 0); // GetEDDB(); // GetFile(); InvokeRepeating("UpdateLists", 0, 1); if (new FileInfo(MissionPath).Length == 0) { Debug.Log("File Empty"); } else { string missiondata = File.ReadAllText(MissionPath); Debug.Log(missiondata); ActiveMissionList = JsonConvert.DeserializeObject <List <MissionAdd> >(missiondata); Debug.Log(ActiveMissionList.Count); } }
// Use this for initialization void Start() { Debug.Log("API AI Initialized."); const string ACCESS_TOKEN = "c1cb6e5396d04d6e8b1215ac0cfd55ac"; var config = new AIConfiguration(ACCESS_TOKEN, SupportedLanguage.English); apiAiUnity = new ApiAiUnity(); apiAiUnity.Initialize(config); //SendText("Do you know what is the definition of insanity is?"); Recognitions.text = ""; DictationRecognizer = new DictationRecognizer(); DictationRecognizer.DictationResult += (text, confidence) => { Debug.LogFormat("Dictation result: {0}", text); Recognitions.text = text; SendText(text); }; DictationRecognizer.DictationComplete += (completionCause) => { if (completionCause != DictationCompletionCause.Complete) { Debug.LogErrorFormat("Dictation completed unsuccessfully: {0}.", completionCause); } }; DictationRecognizer.DictationError += (error, hresult) => { Debug.LogErrorFormat("Dictation error: {0}; HResult = {1}.", error, hresult); }; DictationRecognizer.Start(); WindowsVoice.speak("shut up"); }
IEnumerator SendChat(ChatData chatData) { WWWForm form = new WWWForm(); form.AddField("apikey", chatData.apiKey); form.AddField("query", chatData.message, Encoding.UTF8); // 通信 using (UnityWebRequest request = UnityWebRequest.Post(chatData.endPoint, form)) { yield return(request.Send()); if (request.isNetworkError) { Debug.Log(request.error); } else { try { // 取得したものをJsonで整形 string itemJson = request.downloadHandler.text; JsonNode jsnode = JsonNode.Parse(itemJson); // Jsonから会話部分だけ抽出してTextに代入 //if (text.text != null) //{ // text.text = jsnode["results"][0]["reply"].Get<string>(); //} Debug.Log(jsnode["results"][0]["reply"].Get <string>()); m_AvatarInput.text = jsnode["results"][0]["reply"].Get <string>(); WindowsVoice.speak(jsnode["results"][0]["reply"].Get <string>()); } catch (Exception e) { // エラーが出たらこれがログに吐き出される Debug.Log("JsonNode:" + e.Message); } } } }
void Update() { if (Input.GetKeyDown("r")) { if (PTT == false) { // if(Active == false) // { TriggerWatson(); // } StartRecording(); WindowsVoice.speak("Yes Commander", 0); PTT = true; } else { StopRecording(); PTT = false; } } }
public static void PlayTextToSpeech(string text) { VoiceObj.speak(text); }
void ChatMode() { ChatModeToggle = true; IS.Keyboard.KeyDown(VirtualKeyCode.VK_A); WindowsVoice.speak("Chat Mode", 0); }
private void speakWord(ChallengeWord word) { WindowsVoice.speak($"Select the word {word.Word}"); }
void RunChallengeMode() { if (LevelCompleted == false && ChallengeMode) { // select random challenge word if (!challengeModeWords.Any(w => w.IsCurrentWord)) { ChallengeWord randomWord = getRandomChallengeModeWord(challengeModeWords); randomWord.IsCurrentWord = true; speakWord(randomWord); } // var selectedWord = challengeModeWords.SingleOrDefault(c => c.IsSelected); // if word is not selected select one at random if (selectedWord == null) { getRandomChallengeModeWord(challengeModeWords).IsSelected = true; } // update coloring for text foreach (var node in challengeModeWords) { if (node.IsSelected) { node.ChallengeModeWordText.color = Color.cyan; } else { node.ChallengeModeWordText.color = Color.white; } } // Left if (Time.time > timestamp && Input.GetAxis("Horizontal") < 0.0f) { var selectedNode = challengeModeWords.Find(selectedWord); if (selectedNode.Previous != null) { selectedNode.Previous.Value.IsSelected = true; selectedWord.IsSelected = false; } timestamp = Time.time + timeBetweenChallengeSelect; } // right else if (Time.time > timestamp && Input.GetAxis("Horizontal") > 0.0f) { var selectedNode = challengeModeWords.Find(selectedWord); if (selectedNode.Next != null) { selectedNode.Next.Value.IsSelected = true; selectedWord.IsSelected = false; } timestamp = Time.time + timeBetweenChallengeSelect; } else if (Input.GetButtonDown("Submit")) { if (selectedWord.IsCurrentWord) { WindowsVoice.speak("That is correct!"); Destroy(selectedWord.ChallengeModeWordText); challengeModeWords.Remove(selectedWord); // Level has been completed LevelCompleted = !challengeModeWords.Any(); } else { WindowsVoice.speak("That is incorrect!"); } } } }
//void SelectFaction() //{ // GameObject Menu; // Menu = GameObject.Find("MenuSystem"); // int FactionCount=0; // foreach (var faction in GetComponent<GrabLog>().FactionSystems) // { // if (faction.SystemName == GetComponent<GrabLog>().StarSystem) // { // FactionCount++; // if(FactionCount == int.Parse(VariableText)) // { // FactionName = faction.FactionName; // } // } // } // if (int.Parse(VariableText) > FactionCount) // { // Menu.GetComponent<MenuAnimations>().SelectFaction("", true); // } // else // { // Menu.GetComponent<MenuAnimations>().SelectFaction(FactionName, false); // ActiveMission = int.Parse(VariableText); // } //} public void MissionSpeech() { WindowsVoice.speak("retrieving message... message Reads: " + GetComponent <GrabLog>().ActiveMissionList[ActiveMission].Story, 0); }
public void HandleIntent(EventMessageObject nluAnswer) { AIResponse nluResponse = (AIResponse)nluAnswer.MessageBody; Debug.Log("##### Habe folgenden Intent erkannt und möchte ihn jetzt verarbeiten: " + nluResponse.Result.Metadata.IntentName); //Dialog Delegation prüfen Debug.Log("Überprüfe ob noch Slots fehlen: "); //AIOutputContext context = nluResponse.Result.GetContext(); AIOutputContext[] context = nluResponse.Result.Contexts; bool slotsMissing = false; foreach (AIOutputContext con in context) { Debug.Log(con.Name); if (con.Name.Contains("dialog_context")) { slotsMissing = true; } } if (slotsMissing) { wasInDialogDelegationLastRound = true; //damit nächster Intent sieht, ob DialogDelegation zuvor aktiv war slotMissingRounds++; Debug.Log("Es fehlen noch Slotbelegungen. Ich gebe die Kontrolle an TTS"); //Debug.Log("WWE Status " + asr.WakeWordState); //Debug.Log("STT Status " + asr.DictationState); EventManager.TriggerEvent(EventManager.keywordDetectedEvent, new EventMessageObject(EventManager.keywordDetectedEvent, "Slots fehlen")); //actions.DisplayText(debugText, nluResponse.Result.Fulfillment.Speech); string cancelInfo = ""; if (slotMissingRounds > 1) { cancelInfo = "Du kannst ungewollte Anfragen jederzeit beenden, indem du abbrechen sagst."; } WindowsVoice.speak(string.Format("{0} {1}", cancelInfo, nluResponse.Result.Fulfillment.Speech), delay: 0f); } //ansonsten rufe die Handler auf else { slotMissingRounds = 0; Debug.Log("Alle Slots gefüllt:"); Dictionary <String, System.Object> dic = nluResponse.Result.Parameters; foreach (String key in dic.Keys) { Debug.Log(string.Format("Parameter: {0}", key)); } actions.DisplayText(debugText, nluResponse.Result.Fulfillment.Speech); String intent = nluResponse.Result.Metadata.IntentName; Result nluResultObj = nluResponse.Result; //Ausgabe der Dialogflow Response -> Metadata.EndConversation Boolean bestimmt ob als Frage oder Aussage //***Kann in Unity JSON Objekt bisher nicht abgerufen werden -> Parameter: endConversation simuliert ihn bool canceledDialogDelegation = nluResponse.Result.ResolvedQuery.Equals("abbrechen") && wasInDialogDelegationLastRound ? true:false; //Dialogflow eigenes Abbrechen simuliert endConversation nicht if (nluResultObj.Fulfillment.Speech != "") { if (nluResultObj.GetStringParameter("endConversation").Equals("true") || canceledDialogDelegation) //***evtl. muss hier eine Abfrage rein die beim default fallback auch das mikrofon schließt { actions.Speak(nluResultObj.Fulfillment.Speech); } else //ansonsten öffne das Mikrofon wieder { actions.AskQuestion(nluResultObj.Fulfillment.Speech); } } String action = nluResponse.Result.Action; bool noActionIntent = false; //wird true falls der Intent keine Action enthält oder diese nicht implementiert ist switch (action) { /*case IPAAction.askQuestion: * actions.AskQuestion(nluResultObj.GetStringParameter("speak")); * break; * * * case IPAAction.speak: * actions.Speak(nluResultObj.GetStringParameter("speak")); * break;*/ //Intents zur Fahrzeugsteuerung case IPAAction.moveCar: String groesseneinheit = nluResultObj.GetStringParameter("Groesseneinheit"); String direction = nluResultObj.GetStringParameter("MoveDirection"); actions.MoveCar(groesseneinheit, direction); break; case IPAAction.stopCar: actions.StopCarMovement(); break; case IPAAction.takeCarControl: actions.TakeCarControl(); break; case IPAAction.getCarControlBack: actions.GetCarControlBack(); break; case IPAAction.takePlateControl: actions.TakePlateControl(); break; case IPAAction.getPlateControlBack: actions.GetPlateControlBack(); break; //Map Manipulation Intents: case IPAAction.openMap: actions.OpenMap(); break; case IPAAction.closeMap: actions.CloseMap(); actions.SetMinimapFokusOnCar(); break; case IPAAction.saveNavigationPoint: actions.SaveNavigationPoint(minimapLocationIcon); break; case IPAAction.deleteNavigationPoint: int zielNummer2 = Int32.Parse(nluResultObj.GetStringParameter("navigationNumber")); actions.DeleteNavigationPoint(zielNummer2); break; case IPAAction.changeMapFixedStep: groesseneinheit = nluResponse.Result.GetStringParameter("Groesseneinheit"); direction = nluResponse.Result.GetStringParameter("Direction"); if (direction.Length == 0) { direction = nluResponse.Result.GetStringParameter("MoveDirection"); } actions.ChangMapFixedStep(groesseneinheit, direction); break; case IPAAction.focusOnCar: actions.SetMinimapFokusOnCar(); break; //Navigation Intents: case IPAAction.startNavigation: int zielNummer = Int32.Parse(nluResultObj.GetStringParameter("navigationNumber")); if (sharedData.savedPlacesOnMap.Count > zielNummer - 1) { Vector3 target = sharedData.savedPlacesOnMap[zielNummer - 1].transform.position; actions.StartNavigation(target); } else { WindowsVoice.speak(string.Format("Ich konnte keinen Ort mit Nummer {0} finden.", zielNummer), 3); } break; case IPAAction.endNavigation: actions.EndNavigation(); break; //Intents zur Unterstützung der Teststreckenerstellung case IPAAction.restartTraining: SceneManager.LoadScene("Level1Training"); // Todo:Index auf Namen der Szene ändern break; case IPAAction.setCheckpoint: actions.SetTrainingCheckpoint(sharedData.currentFrameCount); actions.Speak("Sicherungspunkt erstellt bei Frame:" + sharedData.currentFrameCount); break; case IPAAction.discardCheckpoint: actions.SetTrainingCheckpoint(0); break; case IPAAction.endTrainingRouteCreation: actions.EndTraining(); /*sharedData.trainingRouteRecordingStopped = true; //Beendet hinzufügen neuer Framestrokes in AlternateCarController * * * //Entferne PlayerControl und Ball * sharedData.SetPlayerControl(false); * GameObject.FindGameObjectWithTag("Ball").SetActive(false); * if (String.IsNullOrEmpty(sharedData.playerName)) * { * Debug.LogError("Fehler bei Namenserfassung. Öffne Texteingabe."); * GameObject.Find("NameQuestionCanvas").GetComponent<Canvas>().enabled = true; * }*/ break; case IPAAction.performanceAndDifficultyMeasured: bool performanceOK = nluResultObj.GetStringParameter("Performance").Equals("gut") ? true : false; if (sharedData.debugMode && performanceOK) { //Debug.LogError(WindowsVoice.statusMessage); sharedData.trainingRouteDifficulty = nluResultObj.GetStringParameter("Difficulty") + "/"; //sobald gesetzt schreibt AlternateCarController die Route entsprechend ca Codezeile 500 //Beende verzögert StartCoroutine(SharedFields.DelayedQuit(10f)); } else { Debug.LogError(nluResultObj.GetStringParameter("Performance")); actions.Speak("Verwerfe Strecke aufgrund schlechter Performance. Beende Programm"); IEnumerator co = SharedFields.DelayedQuit(10f); StartCoroutine(co); //Application.Quit(); } break; case IPAAction.wantToSetContext: int firstFreeContext = context.Length; AIOutputContext[] newContext = new AIOutputContext[firstFreeContext + 1]; AIOutputContext contextToInsert = new AIOutputContext(); contextToInsert.Name = "TestContext"; contextToInsert.Lifespan = 3; newContext[firstFreeContext] = contextToInsert; context = newContext; Debug.Log("So sollte es aussehen:"); foreach (AIOutputContext con in context) { Debug.Log(con.Name); if (con.Name.Contains("dialog_context")) { slotsMissing = true; } } Debug.Log("Trigger SpeechCommandRecognized to send new Context to Dialogflow"); EventManager.TriggerEvent(EventManager.asrRequerstDetectedEvent, new EventMessageObject(EventManager.asrRequerstDetectedEvent, string.Format("Rueckantwort Kontext einfuegen"))); break; case IPAAction.setContext: Debug.Log("Habe Kontext gesetzt."); foreach (AIOutputContext con in context) { Debug.Log(con.Name); if (con.Name.Contains("dialog_context")) { slotsMissing = true; } } break; //PlayerInfo case IPAAction.setPlayerName: //var outText = NewJSon::Newtonsoft.Json.JsonConvert.SerializeObject(nluResultObj.GetJsonParameter("UserName"), jsonSettings); //Debug.LogError(outText); string name = ""; //Sonderbehandlung falls Dialogflow Entitie givenName benutzt -> bekomme neues Dict statt String Dictionary <string, object> parameterDict = nluResultObj.Parameters; Type t = parameterDict["UserName"].GetType(); bool isDict = t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Dictionary <,>); Dictionary <string, object> givenNameEntitie; if (isDict) { givenNameEntitie = (Dictionary <string, object>)parameterDict["UserName"]; try { name = (string)givenNameEntitie["given-name"]; } catch (KeyNotFoundException) { name = (string)givenNameEntitie["MapStringsToName"]; } } else { name = nluResultObj.GetStringParameter("UserName"); } //Debug.LogErrorFormat("is dict? {0}", isDict); //Debug.LogError( parameterDict["UserName"].GetType()); Debug.LogError("Haben folgenden Namen erkannt: " + name); if (String.IsNullOrEmpty(name)) { Debug.LogError("******Name konnte nicht gesetzt werden. Baue erneute Nachfrage ein?"); } actions.SetPlayerName(name); Debug.LogError("Der neue Name ist: " + sharedData.playerName); break; case IPAAction.rename: EventManager.TriggerEvent(EventManager.asrRequerstDetectedEvent, new EventMessageObject(EventManager.asrRequerstDetectedEvent, "Spielerwechsel")); break; //Allgemeine Befehle: case IPAAction.repeatAnswer: actions.Speak(lastIPAspeech); break; case IPAAction.repeatLastAction: if (repeatableTasksDict.ContainsKey(lastIPAAction)) { EventManager.TriggerEvent(EventManager.asrRequerstDetectedEvent, new EventMessageObject(EventManager.asrRequerstDetectedEvent, repeatableTasksDict[lastIPAAction])); } break; case IPAAction.undo: string undoAction = ""; Debug.LogError("Last Action was: " + lastIPAAction); if (symmetricTasksDict.ContainsKey(lastIPAAction)) { undoAction = symmetricTasksDict[lastIPAAction]; } else if (symmetricTasksDict.ContainsValue(lastIPAAction)) { foreach (KeyValuePair <string, string> keyValue in symmetricTasksDict) { if (keyValue.Value.Equals(lastIPAAction)) { undoAction = keyValue.Key; } } } else { Debug.LogErrorFormat("Der letzte Task hatte keine Implementierung eines symmetrischen Gegenparts"); WindowsVoice.speak("Der letzte Task hatte keine Implementierung eines symmetrischen Gegenparts", 2); } if (eventTriggerStringForActionDict.ContainsKey(undoAction)) { string voiceCommandForUndoAction = eventTriggerStringForActionDict[undoAction]; EventManager.TriggerEvent(EventManager.asrRequerstDetectedEvent, new EventMessageObject(EventManager.asrRequerstDetectedEvent, voiceCommandForUndoAction)); } else { actions.Speak("Ich kann die letzte Aktion nicht rueckgängig machen. Die eingetragenen Funktionspaare funktionieren nur in die andere Richtung."); } break; case IPAAction.wantMoreHelp: //Ermittle zuletzt thematisierte Kategorie und simuliere eine entsprechende Anfrage an die NLU int navigationHelpSessionCount = 0; int mlTrainingHelpSessionCount = 0; int driveHelpSessionCount = 0; foreach (AIOutputContext currentContext in nluResponse.Result.Contexts) { string contextName = currentContext.Name; if (contextName.Equals("mltraininghelprequested")) { Debug.Log("habe training kontext"); mlTrainingHelpSessionCount += (int)currentContext.Lifespan; } else if (context.Equals("navigationhelprequested")) { Debug.Log("habe navigation kontext"); navigationHelpSessionCount += (int)currentContext.Lifespan; } else if (context.Equals("drivehelprequested")) { Debug.Log("habe drive kontext"); driveHelpSessionCount += (int)currentContext.Lifespan; } } if (navigationHelpSessionCount > Math.Max(mlTrainingHelpSessionCount, driveHelpSessionCount)) { EventManager.TriggerEvent(EventManager.asrRequerstDetectedEvent, new EventMessageObject(EventManager.asrRequerstDetectedEvent, "Ich brauche Hilfe in der Kategorie Fahren.")); } else if (mlTrainingHelpSessionCount > Math.Max(navigationHelpSessionCount, driveHelpSessionCount)) { EventManager.TriggerEvent(EventManager.asrRequerstDetectedEvent, new EventMessageObject(EventManager.asrRequerstDetectedEvent, "Hilf mir beim trainieren")); } else if (driveHelpSessionCount > Math.Max(navigationHelpSessionCount, mlTrainingHelpSessionCount)) { EventManager.TriggerEvent(EventManager.asrRequerstDetectedEvent, new EventMessageObject(EventManager.asrRequerstDetectedEvent, "Hilf mir beim Navigieren")); } else { Debug.LogFormat("Konnte kein Event auslösen: navigationHelpSessionCount {0} mlTrainingHelpSessionCount{1}, driveHelpSessionCount {2}", navigationHelpSessionCount, mlTrainingHelpSessionCount, driveHelpSessionCount); } break; case IPAAction.continueGame: actions.ContinueGame(); break; case IPAAction.pauseGame: actions.PauseGame(); break; case IPAAction.quitGame: Application.Quit(); break; default: Debug.Log(string.Format("Der Intent {0} wurde im IntentHandler nicht registiert.", intent)); noActionIntent = true; //WindowsVoice.speak("Diesen Intent kenne ich nicht", 0f); //wird von Fallback Intent in Block unten gemacht break; } //Die letzte Aktion soll von Intents ohne Action nicht überschrieben werden if (!noActionIntent) { lastIPAAction = action; } } lastIPAspeech = nluResponse.Result.Fulfillment.Speech; Debug.LogError(lastIPAspeech + " ist zuletzt gesagtes"); }
public override float Act(bool qUndo = false) { WindowsVoice.speak("Game Over."); GameGUI.theGameGUI.draw(); return(0); }