/// <summary> /// Build mlf from unit. /// </summary> /// <param name="unit">Unit.</param> /// <param name="item">Script item.</param> /// <param name="sw">Text writer.</param> /// <param name="writeToFile">Whethe writing to file.</param> /// <param name="phoneme">Phoneme.</param> /// <returns>Errors.</returns> private static ErrorSet BuildMonoMlf(TtsUnit unit, ScriptItem item, StreamWriter sw, bool writeToFile, Phoneme phoneme) { Debug.Assert(unit != null); Debug.Assert(item != null); ErrorSet errors = new ErrorSet(); List<string> allPhones = new List<string>(); foreach (TtsMetaPhone phone in unit.MetaUnit.Phones) { string[] srPhones = phoneme.Tts2SrPhones(phone.Name); if (srPhones == null) { string message = string.Format(CultureInfo.InvariantCulture, "Invalid TTS phone[{0}], which can not be converted to Speech Recognition Phone.", phone.Name); errors.Add(ScriptError.OtherErrors, item.Id, message); continue; } allPhones.AddRange(srPhones); } if (writeToFile) { foreach (string phone in allPhones) { sw.WriteLine(phone); } } return errors; }
/// <summary> /// Build mlf from syllable. /// </summary> /// <param name="syllable">Syllable.</param> /// <param name="item">Script item.</param> /// <param name="sw">Text writer.</param> /// <param name="writeToFile">Whethe writing to file.</param> /// <param name="phoneme">Phoneme.</param> /// <returns>Errors.</returns> private static ErrorSet BuildMonoMlf(ScriptSyllable syllable, ScriptItem item, StreamWriter sw, bool writeToFile, Phoneme phoneme) { Debug.Assert(syllable != null); Debug.Assert(item != null); ErrorSet errors = new ErrorSet(); string syllableText = Pronunciation.RemoveStress(syllable.Text.Trim()); string[] srPhones = phoneme.Tts2SrPhones(syllableText.Trim()); if (srPhones == null) { string message = string.Format(CultureInfo.InvariantCulture, "Invalid TTS syllable[{0}], which can not be converted to Speech Recognition Phone.", syllableText); errors.Add(ScriptError.OtherErrors, item.Id, message); } if (writeToFile && srPhones != null) { foreach (string phone in srPhones) { sw.WriteLine(phone); } } return errors; }