示例#1
0
        private Speaker()
        {
            if (synthesizer == null)
            {
                synthesizer        = new SpeechSynthesizer();
                synthesizer.Volume = 100;
            }

            if (InstalledVoices == null)
            {
                InstalledVoices = new List <InstalledVoice>();
            }

            // インストール済みのSAPIなボイスを列挙
            foreach (InstalledVoice voice in synthesizer.GetInstalledVoices())
            {
                // メンバ変数へ列挙されたボイスを追加。
                if (voice != null)
                {
                    InstalledVoices.Add(voice);
                }
            }

            synthesizer.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(OnSAPISpeakingEnd);
            synthesizer.SpeakProgress  += new EventHandler <SpeakProgressEventArgs>(OnSAPISpeakingSentence);
        }
示例#2
0
        public static void LoadSettings()
        {
            var xml = SettingsManager.Options.VoicesData;

            InstalledVoiceEx[] savedVoices = null;
            if (!string.IsNullOrEmpty(xml))
            {
                try { savedVoices = Serializer.DeserializeFromXmlString <InstalledVoiceEx[]>(xml); }
                catch (Exception) { }
            }
            if (savedVoices == null)
            {
                savedVoices = new InstalledVoiceEx[0];
            }
            foreach (var voice in savedVoices)
            {
                // If voice is not missing information then...
                if (!string.IsNullOrEmpty(voice.SourceKeys))
                {
                    InstalledVoices.Add(voice);
                }
            }
        }