public void FactoryReset(Sentence newSentence) { surroundingPhrase = string.Empty; PreviousProcessUsedDictionary = false; WrongFormatMatches = 0; WrongFormatNonMatches = 0; currentResults.Clear(); dictionaryMatch = null; tempSentence = newSentence; pushingDictionaryWordOut = false; WordIsolator.FactoryReset(newSentence); }
/// <summary> /// first searches the dictionary, then tries adjacent evaluation if no match found. /// Returns new list. /// </summary> /// <param name="sentence"></param> /// <param name="letterIndex"></param> /// <returns>returns new list.</returns> public List <string> GetLettersPronunciation(int letterIndex) { pushingDictionaryWordOut = false; currentResults = new List <string>(); WordIsolator.MoveNext(); //Incrementing the WordIsolator must happen at the beginning of a new letter analysis. This is so optional debugger can pick up accurate properties after each letter analysis. currentResults.Clear(); surroundingPhrase = string.Empty; if (WordIsolator.Current != Constants.SPACE.ToString()) { if (WordIsolator.CurrentWordIsNew == true) { dictionaryMatch = null; PreviousProcessUsedDictionary = false; //prevent false positives PreviousProcessUsedDictionary = PrettyScaryDictionary.TTS_DICTIONARY.TryGetValue(WordIsolator.Current, out dictionaryMatch); if (PreviousProcessUsedDictionary) { TakeFromDictionary(); } else { AdjacentEvaluation(letterIndex); } } else if (PreviousProcessUsedDictionary) { TakeFromDictionary(); } else { AdjacentEvaluation(letterIndex); } } else { currentResults.Add(Constants.SPACE.ToString()); //avoids setting WordIsolator.LetterIndex in this scenario since an empty space cant reset it when needed. } if (OutputManager.IsDebugging == false) //debugger only checks that the correct phonemes were selected; doesnt care about intonation { bool sentenceIsEnding = (letterIndex >= tempSentence.Length - SENTENCE_END_ZONES_LENGTH) ? true : false; for (int i = default(int); i < currentResults.Count; i++) { bool lastVowelSoon = default(bool); if (sentenceIsEnding && pushingDictionaryWordOut && i < currentResults.Count - SENTENCE_END_ZONES_LENGTH) { lastVowelSoon = false; //prevents TakeFromDictionary() from applying the sentence end state to its entire word push. } currentResults[i] = intonationGen.GetPhonemesIntonation(currentResults[i], surroundingPhrase, lastVowelSoon); } } return(currentResults); }