/// <summary>
        /// Validate language data files.
        /// </summary>
        /// <param name="language">Language of the data files.</param>
        /// <returns>Error set.</returns>
        public ErrorSet ValidateLanguageData(Language language)
        {
            ErrorSet errorSet = new ErrorSet();
            if (!IsEmpty())
            {
                if (!string.IsNullOrEmpty(_phoneSet))
                {
                    TtsPhoneSet ttsPhoneSet = new TtsPhoneSet();
                    ttsPhoneSet.Load(PhoneSet);
                    if (ttsPhoneSet.Language != language)
                    {
                        errorSet.Add(new Error(VoiceCreationLanguageDataError.MismatchLanguage,
                            Localor.LanguageToString(language),
                            Localor.LanguageToString(ttsPhoneSet.Language),
                            Localor.PhoneSetFileName, PhoneSet));
                    }
                }

                if (!string.IsNullOrEmpty(_unitTable))
                {
                    SliceData sliceData = new SliceData();
                    sliceData.Language = language;
                    sliceData.Load(UnitTable);
                    if (sliceData.IsEmpty())
                    {
                        errorSet.Add(new Error(VoiceCreationLanguageDataError.EmptyLanguageDataFile,
                            Localor.LanguageToString(language),
                            Localor.UnitTableFileName, UnitTable));
                    }
                }

                if (!string.IsNullOrEmpty(_lexicalAttributeSchema))
                {
                    LexicalAttributeSchema lexicalAttributeSchema = new LexicalAttributeSchema();
                    lexicalAttributeSchema.Load(LexicalAttributeSchema);
                    if (lexicalAttributeSchema.Language != language)
                    {
                        errorSet.Add(new Error(VoiceCreationLanguageDataError.MismatchLanguage,
                            Localor.LanguageToString(language),
                            Localor.LanguageToString(lexicalAttributeSchema.Language),
                            Localor.PhoneSetFileName, LexicalAttributeSchema));
                    }
                }

                if (!string.IsNullOrEmpty(_truncateRule))
                {
                    TruncateRuleData truncateRuleData = new TruncateRuleData();
                    truncateRuleData.Load(TruncateRule);
                    if (truncateRuleData.Language != language)
                    {
                        errorSet.Add(new Error(VoiceCreationLanguageDataError.MismatchLanguage,
                            Localor.LanguageToString(language),
                            Localor.LanguageToString(truncateRuleData.Language),
                            Localor.TruncateRulesFileName, TruncateRule));
                    }
                }

                if (!string.IsNullOrEmpty(_ttsToSapiVisemeId))
                {
                    PhoneMap phoneMap = PhoneMap.CreatePhoneMap(TtsToSapiVisemeId);
                    if (phoneMap.Language != language)
                    {
                        errorSet.Add(new Error(VoiceCreationLanguageDataError.MismatchLanguage,
                            Localor.LanguageToString(language),
                            Localor.LanguageToString(phoneMap.Language),
                            Localor.TtsToSapiVisemeIdFileName, TtsToSapiVisemeId));
                    }
                }

                if (!string.IsNullOrEmpty(_ttsToSrPhone))
                {
                    PhoneMap phoneMap = PhoneMap.CreatePhoneMap(TtsToSrPhone);
                    if (phoneMap.Language != language)
                    {
                        errorSet.Add(new Error(VoiceCreationLanguageDataError.MismatchLanguage,
                            Localor.LanguageToString(language),
                            Localor.LanguageToString(phoneMap.Language),
                            Localor.TtsToSrPhoneFileName, TtsToSrPhone));
                    }
                }

                if (!string.IsNullOrEmpty(_ttsToIpaPhone))
                {
                    PhoneMap phoneMap = PhoneMap.CreatePhoneMap(TtsToIpaPhone);
                    if (phoneMap.Language != language)
                    {
                        errorSet.Add(new Error(VoiceCreationLanguageDataError.MismatchLanguage,
                            Localor.LanguageToString(language),
                            Localor.LanguageToString(phoneMap.Language),
                            Localor.TtsToIpaPhoneFileName, TtsToIpaPhone));
                    }
                }

                if (!string.IsNullOrEmpty(_fontMeta))
                {
                    PhoneMap phoneMap = PhoneMap.CreatePhoneMap(FontMeta);
                    if (phoneMap.Language != language)
                    {
                        errorSet.Add(new Error(VoiceCreationLanguageDataError.MismatchLanguage,
                            Localor.LanguageToString(language),
                            Localor.LanguageToString(phoneMap.Language),
                            Localor.FontMetaFileName, FontMeta));
                    }
                }
            }
            else
            {
                Trace.WriteLine("Using stocked language data with tools...");
            }

            return errorSet;
        }
Example #2
0
        private static TruncateRuleData LoadTruncateRuleData(Language language)
        {
            TruncateRuleData truncateRule = null;

            using (StreamReader ruleReader = LoadResource(language, Localor.TruncateRulesFileName))
            {
                if (ruleReader != null)
                {
                    truncateRule = new TruncateRuleData();
                    truncateRule.Language = language;
                    truncateRule.Load(ruleReader);
                }
            }

            return truncateRule;
        }