Beispiel #1
0
        internal VoiceInfo(ObjectToken token)
        {
            _registryKeyPath = token._sKeyId;
            _id          = token.Name;
            _description = token.Description;
            _name        = token.TokenName();
            SsmlParserHelpers.TryConvertAge(token.Age.ToLowerInvariant(), out _age);
            SsmlParserHelpers.TryConvertGender(token.Gender.ToLowerInvariant(), out _gender);
            string value;

            if (token.Attributes.TryGetString("Language", out value))
            {
                _culture = SapiAttributeParser.GetCultureInfoFromLanguageString(value);
            }
            string value2;

            if (token.TryGetString("Assembly", out value2))
            {
                _assemblyName = value2;
            }
            string value3;

            if (token.TryGetString("CLSID", out value3))
            {
                _clsid = value3;
            }
            if (token.Attributes != null)
            {
                Dictionary <string, string> dictionary = new Dictionary <string, string>();
                string[] valueNames = token.Attributes.GetValueNames();
                foreach (string text in valueNames)
                {
                    string value4;
                    if (token.Attributes.TryGetString(text, out value4))
                    {
                        dictionary.Add(text, value4);
                    }
                }
                _attributes = new ReadOnlyDictionary <string, string>(dictionary);
            }
            string value5;

            if (token.Attributes != null && token.Attributes.TryGetString("AudioFormats", out value5))
            {
                _audioFormats = new ReadOnlyCollection <SpeechAudioFormatInfo>(SapiAttributeParser.GetAudioFormatsFromString(value5));
            }
            else
            {
                _audioFormats = new ReadOnlyCollection <SpeechAudioFormatInfo>(new List <SpeechAudioFormatInfo>());
            }
        }
Beispiel #2
0
        internal VoiceInfo(ObjectToken token)
        {
            _registryKeyPath = token._sKeyId;

            // Retrieve the token name
            _id = token.Name;

            // Retrieve default display name
            _description = token.Description;

            // Get other attributes
            _name = token.TokenName();
            SsmlParserHelpers.TryConvertAge(token.Age.ToLowerInvariant(), out _age);
            SsmlParserHelpers.TryConvertGender(token.Gender.ToLowerInvariant(), out _gender);

            string langId;

            if (token.Attributes.TryGetString("Language", out langId))
            {
                _culture = SapiAttributeParser.GetCultureInfoFromLanguageString(langId);
            }

            string assemblyName;

            if (token.TryGetString("Assembly", out assemblyName))
            {
                _assemblyName = assemblyName;
            }

            string clsid;

            if (token.TryGetString("CLSID", out clsid))
            {
                _clsid = clsid;
            }

            if (token.Attributes != null)
            {
                // Enum all values and add to custom table
                Dictionary <string, string> attrs = new();
                foreach (string keyName in token.Attributes.GetValueNames())
                {
                    string attributeValue;
                    if (token.Attributes.TryGetString(keyName, out attributeValue))
                    {
                        attrs.Add(keyName, attributeValue);
                    }
                }
                _attributes = new ReadOnlyDictionary <string, string>(attrs);
            }

            string audioFormats;

            if (token.Attributes != null && token.Attributes.TryGetString("AudioFormats", out audioFormats))
            {
                _audioFormats = new ReadOnlyCollection <SpeechAudioFormatInfo>(SapiAttributeParser.GetAudioFormatsFromString(audioFormats));
            }
            else
            {
                _audioFormats = new ReadOnlyCollection <SpeechAudioFormatInfo>(new List <SpeechAudioFormatInfo>());
            }
        }