本文整理汇总了C#中ErrorSet.ErrorsString方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorSet.ErrorsString方法的具体用法?C# ErrorSet.ErrorsString怎么用?C# ErrorSet.ErrorsString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorSet
的用法示例。
在下文中一共展示了ErrorSet.ErrorsString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseStringToSyllable
/// <summary>
/// Parsing the syllable string to a script syllable
/// Here we suppose syllable is a valid pronunciation string.
/// </summary>
/// <param name="syllable">Syllable string, doesn't include unit boundary.</param>
/// <param name="phoneSet">TtsPhoneSet.</param>
/// <returns>The constructed script syllable.</returns>
public static ScriptSyllable ParseStringToSyllable(string syllable, TtsPhoneSet phoneSet)
{
if (string.IsNullOrEmpty(syllable))
{
throw new ArgumentNullException("syllable");
}
if (phoneSet == null)
{
throw new ArgumentNullException("phoneSet");
}
ScriptSyllable scriptSyllable = new ScriptSyllable(phoneSet.Language);
ErrorSet errors = new ErrorSet();
Phone[] phones = Pronunciation.SplitIntoPhones(syllable, phoneSet, errors);
if (errors.Count > 0)
{
string message = Helper.NeutralFormat(
"The syllable string [{0}] isn't valid : {1}{2}",
syllable, Environment.NewLine, errors.ErrorsString());
throw new InvalidDataException(message);
}
Collection<ScriptPhone> scriptPhones = new Collection<ScriptPhone>();
foreach (Phone phone in phones)
{
if (phone.HasFeature(PhoneFeature.MainStress) ||
phone.HasFeature(PhoneFeature.SubStress))
{
switch (phone.Name)
{
case "1":
scriptSyllable.Stress = TtsStress.Primary;
break;
case "2":
scriptSyllable.Stress = TtsStress.Secondary;
break;
case "3":
scriptSyllable.Stress = TtsStress.Tertiary;
break;
}
}
else if (phone.HasFeature(PhoneFeature.Tone))
{
scriptPhones[scriptPhones.Count - 1].Tone = phone.Name;
}
else
{
ScriptPhone scriptPhone = new ScriptPhone(phone.Name);
scriptPhone.Syllable = scriptSyllable;
scriptPhones.Add(scriptPhone);
}
}
scriptSyllable.Phones.Clear();
Helper.AppendCollection(scriptSyllable.Phones, scriptPhones);
return scriptSyllable;
}