/// <summary> /// Calculate the target cost. /// </summary> /// <param name="condidate">Feature of condidate unit.</param> /// <param name="target">Feature of target unit to find.</param> /// <returns>Cost.</returns> internal float CalcTargetCost(TtsUnitFeature condidate, TtsUnitFeature target) { float targetCost = 0.0f; // position cost: in sentence, in word and in syllable targetCost = CalcTargetCostPosInSentence(condidate.PosInSentence, target.PosInSentence); targetCost += CalcTargetCostPosInWord(condidate.PosInWord, target.PosInWord); targetCost += CalcTargetCostPosInSyl(condidate.PosInSyllable, target.PosInSyllable); // phone context cost: left phone and right phone targetCost += CalcTargetCostLeftContextPhone(condidate.LeftContextPhone, target.LeftContextPhone); targetCost += CalcTargetCostRightContextPhone(condidate.RightContextPhone, target.RightContextPhone); // tone context cost: left tone and right tone targetCost += CalcTargetCostLeftContextTone(condidate.LeftContextTone, target.LeftContextTone); targetCost += CalcTargetCostRightContextTone(condidate.RightContextTone, target.RightContextTone); // stress cost targetCost += CalcTargetCostTtsStress(condidate.TtsStress, target.TtsStress); // emphasis cost targetCost += CalcTargetCostTtsEmphasis(condidate.TtsEmphasis, target.TtsEmphasis); targetCost = targetCost * _totalTargetCostWeight; return targetCost; }
/// <summary> /// Initializes a new instance of the <see cref="TtsUnit"/> class. /// </summary> /// <param name="language">Language for this unit.</param> public TtsUnit(Language language) { _language = language; _languages.Add(_language); Feature = new TtsUnitFeature(); MetaUnit = new TtsMetaUnit(language); }