예제 #1
0
        /// <summary>
        /// Get the list of available installed voices.
        /// </summary>
        /// <returns></returns>
        internal Dictionary <string, AvailableVoice> GetVoices()
        {
            Dictionary <string, AvailableVoice> names = new Dictionary <string, AvailableVoice>();

            // Festival organizes voices by their language.
            // TODO deal with other languages then English
            // TODO Use (voice.list) to fetch the list from Festival
            string path = LIBRARYPATH + "english/";

            // If directory not there, maybe Festival is not installed?
            if (!Directory.Exists(path))
            {
                return(names);
            }

            // Voice names are simply the names of directories.
            foreach (string voicename in Directory.GetDirectories(path))
            {
                string[] terms = voicename.Split('/');
                string   name  = terms[terms.Length - 1];
                bool     male  = true;
                bool     skip  = false;

                // Check for additional information about this voice
                string propString = voiceProperties?[name].AsString();
                if (propString != null)
                {
                    // Properties are a series of blank-separated keywords
                    string[] props = propString.Split(' ');

                    foreach (string key in props)
                    {
                        switch (key)
                        {
                        case "male":
                            male = true;
                            break;

                        case "female":
                            male = false;
                            break;

                        case "ignore":
                            skip = true;
                            break;
                        }
                    }
                }

                // If this voice is not blocked add it to the list.
                if (!skip)
                {
                    names[name] = new LinAvailableVoice(name, male);
                }
            }

            return(names);
        }
예제 #2
0
파일: LinSynth.cs 프로젝트: Booser/radegast
        /// <summary>
        /// Get the list of available installed voices.
        /// </summary>
        /// <returns></returns>
        internal Dictionary<string, AvailableVoice> GetVoices()
        {
            Dictionary<string, AvailableVoice> names = new Dictionary<string, AvailableVoice>();

            // Festival organizes voices by their language.
            // TODO deal with other languages then English
            // TODO Use (voice.list) to fetch the list from Festival
            string path = LIBRARYPATH + "english/";

            // If directory not there, maybe Festival is not installed?
            if (!Directory.Exists(path)) return names;

            // Voice names are simply the names of directories.
            foreach (string voicename in Directory.GetDirectories(path))
            {
				string[] terms = voicename.Split('/');
				string name = terms[terms.Length - 1];
                bool male = true;
                bool skip = false;

                // Check for additional information about this voice
                if (voiceProperties != null)
                {
                    string propString = voiceProperties[name].AsString();
                    if (propString != null)
                    {
                        // Properties are a series of blank-separated keywords
                        string[] props = propString.Split(' ');

                        foreach (string key in props)
                        {
                            switch (key)
                            {
                                case "male":
                                    male = true;
                                    break;
                                case "female":
                                    male = false;
                                    break;
                                case "ignore":
                                    skip = true;
                                    break;
                            }
                        }
                    }
                }

                // If this voice is not blocked add it to the list.
                if (!skip)
                    names[name] = new LinAvailableVoice(name, male);
            }

            return names;
        }