当前位置: 首页>>代码示例>>C#>>正文


C# SpeechSynthesizer.GetInstalledVoices方法代码示例

本文整理汇总了C#中SpeechSynthesizer.GetInstalledVoices方法的典型用法代码示例。如果您正苦于以下问题:C# SpeechSynthesizer.GetInstalledVoices方法的具体用法?C# SpeechSynthesizer.GetInstalledVoices怎么用?C# SpeechSynthesizer.GetInstalledVoices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpeechSynthesizer的用法示例。


在下文中一共展示了SpeechSynthesizer.GetInstalledVoices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: populate_fields

        private void populate_fields()
        {
            List<String> localizations = new List<String>();
            foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
            {
                localizations.Add(ri.Culture.Name);
            }
            cbSettingsLanguage.DataSource = localizations;

            List<String> voices = new List<string>();
            SpeechSynthesizer synthesizer = new SpeechSynthesizer();
            foreach (InstalledVoice voice in synthesizer.GetInstalledVoices())
            {
                voices.Add(voice.VoiceInfo.Name);
            }
            cbSettingsSynthesizer.DataSource = voices;

            List<string> audio_devices = new List<string>();

            //TODO: actually enumerate audio devices.
            audio_devices.Add("Default Directsound device");

            cbSettingsRecordingDevice.DataSource = audio_devices;

            List<string> pushtotalk_mode_list = new List<string>();
            pushtotalk_mode_list.Add("Off");
            pushtotalk_mode_list.Add("Hold");
            pushtotalk_mode_list.Add("PressOnce");
            cbSettingsPushToTalkMode.DataSource = pushtotalk_mode_list;
            cbSettingsPushToTalkMode.SelectedItem = vi_settings.pushtotalk_mode;

            cbSettingsPushToTalkKey.DataSource = Enum.GetValues(typeof(Keys)).Cast<Keys>();
            cbSettingsPushToTalkKey.SelectedItem = Enum.Parse(typeof(Keys), vi_settings.pushtotalk_key);

        }
开发者ID:NotYours180,项目名称:AVPI,代码行数:35,代码来源:frmSettings.cs

示例2: Form1_Load

        private void Form1_Load(object sender, EventArgs e)
        {
            IList<VoiceInfo> voiceInfos = new List<VoiceInfo>();
            var reader = new SpeechSynthesizer();

            var installedVoices = reader.GetInstalledVoices();
            if (installedVoices.Count == 0)
            {
                MessageBox.Show(this,
                    "Your system don't have a 'Text to Speech' to make this work. Try install one for continue.",
                    "Finish", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                foreach (InstalledVoice voice in installedVoices)
                {
                    voiceInfos.Add(voice.VoiceInfo);
                }
                cmbVoice.DataSource = voiceInfos;
                cmbVoice.DisplayMember = "Name";
                cmbVoice.ValueMember = "Id";
            }
            reader.Dispose();
        }
开发者ID:rhpa23,项目名称:TTSrecorder,代码行数:25,代码来源:Form1.cs

示例3: Synthes

 public void Synthes(string textToSpeech)
 {
     SpeechSynthesizer ss = new SpeechSynthesizer();
     var voiceList = ss.GetInstalledVoices();
     ss.SelectVoice(voiceList[2].VoiceInfo.Name); //[0,1] - std english synthesizers, [2] - Nikolay
     ss.Volume = 100; // от 0 до 100
     ss.Rate = 0; //от -10 до 10
     ss.SpeakAsync(textToSpeech);
 }
开发者ID:DenprogIS,项目名称:Charles,代码行数:9,代码来源:Synthesizer.cs

示例4: GetVoices

 public static IEnumerable<string> GetVoices()
 {
     using (var synthesizer = new SpeechSynthesizer())
     {
         var installedVoices = synthesizer.GetInstalledVoices();
         var voices = installedVoices.Where(voice => voice.Enabled);
         return voices.Select(voice => voice.VoiceInfo.Name);
     }
 }
开发者ID:oswellchan,项目名称:PowerPointLabs,代码行数:9,代码来源:TextToSpeech.cs

示例5: SpeechScope

        public SpeechScope(VoiceInfo voiceInfo, params string[] phrases)
        {
            _phrases = phrases;
            _synth = new SpeechSynthesizer();

            _synth.SelectVoice(voiceInfo != null
                ? voiceInfo.Name
                : _synth.GetInstalledVoices()
                    .Where(v => v.VoiceInfo.Culture.Equals(CultureInfo.CurrentCulture))
                    .RandomElement().VoiceInfo.Name);
        }
开发者ID:thomas-parrish,项目名称:Common,代码行数:11,代码来源:SpeechScope.cs

示例6: Speak

 public static void Speak(string text, bool male)
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
     #if WINDOWS
             if (TrySpeech)
             {
                 SpeechSynthesizer speech = new SpeechSynthesizer();
                 VoiceInfo vi = null;
                 foreach (InstalledVoice v in speech.GetInstalledVoices())
                 {
                     if (!v.Enabled)
                     {
                         continue;
                     }
                     if (vi == null)
                     {
                         vi = v.VoiceInfo;
                     }
                     else if ((male && v.VoiceInfo.Gender == VoiceGender.Male) || (!male && v.VoiceInfo.Gender == VoiceGender.Female))
                     {
                         vi = v.VoiceInfo;
                         break;
                     }
                 }
                 if (vi == null)
                 {
                     TrySpeech = false;
                 }
                 else
                 {
                     speech.SelectVoice(vi.Name);
                     speech.Speak(text);
                 }
             }
     #endif
             TrySpeech = false;
         }
         catch (Exception ex)
         {
             Utilities.CheckException(ex);
             TrySpeech = false;
         }
         if (!TrySpeech)
         {
             String addme = male ? " -p 40" : " -p 95";
             Process p = Process.Start("espeak", "\"" + text.Replace("\"", " quote ") + "\"" + addme);
             Console.WriteLine(p.MainModule.FileName);
         }
     });
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:53,代码来源:TextToSpeech.cs

示例7: GetAllVoices

        public static string[] GetAllVoices()
        {
            List<string> voices = new List<string>();
            SpeechSynthesizer synth = new SpeechSynthesizer();

            foreach (InstalledVoice voice in synth.GetInstalledVoices())
            {
                voices.Add(voice.VoiceInfo.Name);
            }

            return voices.ToArray();
        }
开发者ID:3DI70R,项目名称:SpeechSequencerCore,代码行数:12,代码来源:SapiTTS.cs

示例8: TextToSpeechWindows

 public TextToSpeechWindows()
 {
     try
     {
         speechSynthesizer = new SpeechSynthesizer();
         voices = speechSynthesizer.GetInstalledVoices();
     }
     catch (Exception ex)
     {
         Trace.TraceError("voice synthetizer failed: {0}", ex);
     }
 }
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:12,代码来源:TextToSpeechWindows.cs

示例9: ChatToSpeech

 public ChatToSpeech(Spring spring)
 {
     try
     {
         speechSynthesizer = new SpeechSynthesizer();
         voices = speechSynthesizer.GetInstalledVoices();
         spring.LogLineAdded += spring_LogLineAdded;
     }
     catch (Exception ex)
     {
         Trace.TraceError("voice synthetizer failed: {0}", ex);
     }
 }
开发者ID:TurBoss,项目名称:Zero-K-Infrastructure,代码行数:13,代码来源:ChatToSpeech.cs

示例10: GetInstalledVoices

 private IEnumerable<InstalledVoice> GetInstalledVoices()
 {
     using (var synth = new SpeechSynthesizer())
     {
         var installedVoices = synth.GetInstalledVoices();
         Debug.WriteLine("Installed voices -");
         foreach (InstalledVoice voice in installedVoices)
         {
             VoiceInfo info = voice.VoiceInfo;
             Debug.WriteLine(" Voice Name: {0} Culture: {1}", info.Name, info.Culture);
         }
         return installedVoices.ToList();
     }
 }
开发者ID:KenVanGilbergen,项目名称:ken.Speech,代码行数:14,代码来源:SpeechSynthesizerTests.cs

示例11: Post

        public ActionResult Post(IEnumerable<VoiceMessage> voiceMessage)
        {


            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {

                //    // Output information about all of the installed voices. 
                //    Console.WriteLine("Installed voices -");
                foreach (InstalledVoice voice in synth.GetInstalledVoices())
                {
                    VoiceInfo info = voice.VoiceInfo;
                    Console.WriteLine(" Voice Name: " + info.Name);
                }
            } 

            
            
            string toBeVoiced =  string.Empty;
            try
            {
                foreach (var voice in voiceMessage)
                {
                    toBeVoiced = voice.SegmentText;
                    toBeVoiced = toBeVoiced.Replace("<p>", "");
                    toBeVoiced = toBeVoiced.Replace("</p>", "");
                    toBeVoiced = toBeVoiced.Replace("'", "");
                    toBeVoiced = toBeVoiced.Replace("'", "");
                    toBeVoiced = toBeVoiced.Replace("*", "");
                    toBeVoiced = toBeVoiced.Replace(" ", "~");
                    toBeVoiced = toBeVoiced.Replace("<br~/>", "");
                    toBeVoiced = toBeVoiced.Replace("~", " ");

                    VoiceMessage addVoiceMessage = new VoiceMessage();
                    addVoiceMessage.SegmentText = toBeVoiced;
                    addVoiceMessage.IdName = voice.IdName;
                    addVoiceMessage.SegmentName = voice.SegmentName;

                    patientRecords.AddVoicingMessage(addVoiceMessage);
                }
                return new JsonResult { Data = new { Success = true } };
            }
            catch(Exception er)
            {
                string s1 = er.Message;
                return new JsonResult { Data = new { Success = false } };
            }
        }
开发者ID:connecticutortho,项目名称:ct-ortho-repositories4,代码行数:49,代码来源:AddVoiceMessageController.cs

示例12: Main

        static void Main(string[] args)
        {
            if( args.Length != 1)
            {
                Console.WriteLine("Usage: CreateWavFiles.exe file.csv" );
                return;
            }

            var dir = Path.GetDirectoryName(args[0]);
            CsvFile csv = new CsvFile(args[0]);
            dir = Path.Combine(dir,"output");
            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {
                Console.WriteLine("using voice :"+synth.Voice.Name);
                foreach (var item in synth.GetInstalledVoices())
                {
                   //.. Console.WriteLine(item.VoiceInfo.Name);
                }

                for (int i = 0; i < csv.Rows.Count; i++)
                {
                    // Set a value for the speaking rate. Slower to Faster (-10 to 10)
                    synth.Rate = -3;

                    // Configure the audio output.
                    string outputWavFileName = Path.Combine(dir, csv.Rows[i]["File Name"].ToString());
                    Console.WriteLine(outputWavFileName);
                    synth.SetOutputToWaveFile(outputWavFileName,
                      new SpeechAudioFormatInfo(8000, AudioBitsPerSample.Sixteen, AudioChannel.Mono));

              // Create a SoundPlayer instance to play output audio file.
                    //System.Media.SoundPlayer m_SoundPlayer = new System.Media.SoundPlayer(outputWavFileName);

                    // Build a prompt.
                    PromptBuilder builder = new PromptBuilder();
                    builder.AppendText(csv.Rows[i]["Text"].ToString());

                    // Speak the prompt.
                    synth.Speak(builder);
                    //m_SoundPlayer.Play();
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
开发者ID:usbr,项目名称:Pisces,代码行数:48,代码来源:CreateWavFiles.cs

示例13: Application_Start

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // Installed voices
            InstalledVoices = new List<string>();
            using (SpeechSynthesizer speaker = new SpeechSynthesizer()) {
                ReadOnlyCollection<InstalledVoice> voices = speaker.GetInstalledVoices();
                foreach (InstalledVoice voice in voices) {
                    InstalledVoices.Add(voice.VoiceInfo.Name);
                }
            }
        }
开发者ID:infl3x,项目名称:Say-shit-on-my-computer,代码行数:16,代码来源:Global.asax.cs

示例14: FindFullVoiceName

        private static string FindFullVoiceName(string voiceArgument)
        {
            string voiceName = null;
            using (var synthesizer = new SpeechSynthesizer())
            {
                var installedVoices = synthesizer.GetInstalledVoices();
                var enabledVoices = installedVoices.Where(voice => voice.Enabled);

                var selectedVoice = enabledVoices.FirstOrDefault(voice => voice.VoiceInfo.Name.ToLowerInvariant().Contains(voiceArgument));
                if (selectedVoice != null)
                {
                    voiceName = selectedVoice.VoiceInfo.Name;
                }
            }
            return voiceName;
        }
开发者ID:oswellchan,项目名称:PowerPointLabs,代码行数:16,代码来源:StartVoiceTag.cs

示例15: ListInstalledVoices

 public string ListInstalledVoices()
 {
     SpeechSynthesizer voice = new SpeechSynthesizer();
     string ret = (" Installed Voices - Name, Culture, Age, Gender, Description, ID, Enabled\n");
     foreach (InstalledVoice vx in voice.GetInstalledVoices())
     {
         VoiceInfo vi = vx.VoiceInfo;
         ret += ("   " + vi.Name + ", " +
             vi.Culture + ", " +
             vi.Age + ", " +
             vi.Gender + ", " +
             vi.Description + ", " +
             vi.Id + ", " +
             vx.Enabled+"\n");
     }
     return ret;
 }
开发者ID:kingtut666,项目名称:holly,代码行数:17,代码来源:SpeechOut.cs


注:本文中的SpeechSynthesizer.GetInstalledVoices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。