Beispiel #1
0
        private RecognizerInfo(ObjectToken token, CultureInfo culture)
        {
            _id                = token.Name;
            _description       = token.Description;
            _sapiObjectTokenId = token.Id;
            _name              = token.TokenName();
            _culture           = culture;
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            string[] valueNames = token.Attributes.GetValueNames();
            foreach (string text in valueNames)
            {
                string value;
                if (token.Attributes.TryGetString(text, out value))
                {
                    dictionary[text] = value;
                }
            }
            _attributes = new ReadOnlyDictionary <string, string>(dictionary);
            string value2;

            if (token.Attributes.TryGetString("AudioFormats", out value2))
            {
                _supportedAudioFormats = new ReadOnlyCollection <SpeechAudioFormatInfo>(SapiAttributeParser.GetAudioFormatsFromString(value2));
            }
            else
            {
                _supportedAudioFormats = new ReadOnlyCollection <SpeechAudioFormatInfo>(new List <SpeechAudioFormatInfo>());
            }
            _objectToken = token;
        }
        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>());
            }
        }
        private RecognizerInfo(ObjectToken token, CultureInfo culture)
        {
            // Retrieve the token name
            _id = token.Name;

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

            // Store full object token id for internal use.
            // NOTE - SAPI returns the wrong hive for tokenenum tokens (always HKLM).
            // Do not rely on the path to be correct in all cases.
            _sapiObjectTokenId = token.Id;

            _name = token.TokenName();

            _culture = culture;

            // 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[keyName] = attributeValue;
                }
            }
            _attributes = new ReadOnlyDictionary <string, string>(attrs);

            string audioFormats;

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

            _objectToken = token;
        }
Beispiel #4
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>());
            }
        }