private void SpeakPhrase(ModuleUKS2 UKS) { List <Thing> wordsToSpeak = UKS.AnyChildrenFired(UKS.Labeled("Word"), 1, 0, false, true); if (wordsToSpeak.Count == 1) { UKS.Play(wordsToSpeak[0]); talking = true; } wordsToSpeak = UKS.AnyChildrenFired(UKS.Labeled("Phrase"), 1, 0, false, true); if (wordsToSpeak.Count == 1) { SpeakThing(UKS, wordsToSpeak[0]); } }
private void HandlePhonemes(ModuleUKS2 UKS) { List <Thing> phonemes = UKS.AnyChildrenFired(UKS.Labeled("Phoneme"), 1, 0, true, false); List <Thing> phrases = UKS.GetChildren(UKS.Labeled("Phrase")); List <Thing> words = UKS.GetChildren(UKS.Labeled("Word")); //add incoming phonemes to short-term memory and do more processing //if there is a new phoneme, add it to short-term memory //TODO: handle phonemes as they come in rather than waiting for a pause Debug.Assert(phonemes.Count < 2); if (phonemes.Count == 1) { Thing phoneme = phonemes[0]; shortTermMemoryList.Add(phoneme); } if (phonemes.Count == 0 && shortTermMemoryList.Count > 0) //only process if the list isn't empty { if (talking) { talking = false; shortTermMemoryList.Clear(); return; } // MakeWordOfShortInput(UKS, shortTermMemoryList, words); FindPossibleWords(UKS, shortTermMemoryList); List <Thing> bestPhrase = FindBestPhrase(UKS); ConvertUnmatchedPhonemesToWords(UKS, bestPhrase); ExtendWordsWithSinglePhonemes(UKS, bestPhrase, words); Thing phrase = AddPhrase(UKS, bestPhrase); //add a phrase to the text if (currentText != null && phrase != null) { currentText.AddReference(phrase); } //are we matching a text we already know? possiblePhrases.Clear(); shortTermMemoryList.Clear(); } }