/// <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;
        }
Ejemplo n.º 2
0
        private static SliceData LoadSliceData(Language language)
        {
            SliceData sliceData = null;

            using (StreamReader unitTableReader = LoadResource(language, Localor.UnitTableFileName))
            {
                if (unitTableReader != null)
                {
                    sliceData = new SliceData();
                    sliceData.Language = language;
                    sliceData.Load(unitTableReader);
                }
            }

            return sliceData;
        }