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


C# SpeechSynthesizer.SpeakAsync方法代码示例

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


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

示例1: buttonEquals_Click

 private void buttonEquals_Click(object sender, EventArgs e)
 {
     switch (operationPerformed)
     {
         case "+":
             textBox_result.Text = (resultValue + Double.Parse(textBox_result.Text)).ToString();
             break;
         case "-":
             textBox_result.Text = (resultValue - Double.Parse(textBox_result.Text)).ToString();
             break;
         case "*":
             textBox_result.Text = (resultValue * Double.Parse(textBox_result.Text)).ToString();
             break;
         case "/":
             textBox_result.Text = (resultValue / Double.Parse(textBox_result.Text)).ToString();
             break;
         default:
             break;
     }
     resultValue = Double.Parse(textBox_result.Text);
     labelCurrentOperation.Text = "";
     SpeechSynthesizer speech = new SpeechSynthesizer();
     Button button = (Button)sender;
     speech.SpeakAsync(button.Text);
     speech.SpeakAsync(resultValue.ToString());
 }
开发者ID:Fackoz,项目名称:Kalkylator,代码行数:26,代码来源:Form1.cs

示例2: SpeechAsynchrone

 // Méthode permettant de lancer la synthese vocale asynchrone
 //
 public static void SpeechAsynchrone(String texte)
 {
     SpeechSynthesizer s = new SpeechSynthesizer();
     PromptBuilder builder = new PromptBuilder(new System.Globalization.CultureInfo("fr-fr"));
     builder.AppendText(texte);
     s.SpeakAsync(builder);
 }
开发者ID:FabienInspiron,项目名称:ProjetDevintInspiron,代码行数:9,代码来源:Voice.cs

示例3: TestButton_Click

 private void TestButton_Click(object sender, EventArgs e)
 {
     SpeechSynthesizer synth = new SpeechSynthesizer();
     synth.SelectVoice(_settings.CurrentTTSVoice.VoiceInfo.Name);
     synth.Rate = _settings.TTS_Rate;
     synth.SpeakAsync("This is " + _settings.CurrentTTSVoice.VoiceInfo.Description + " Speaking at a rate of " + _settings.TTS_Rate);
 }
开发者ID:sorvis,项目名称:Fast-Script,代码行数:7,代码来源:To_MP3_Options.cs

示例4: SpeakMessage

        public void SpeakMessage(AudioVideoFlow flow, string message)
        {
            try
            {
                SpeechSynthesizer synth = new SpeechSynthesizer();
                SpeechAudioFormatInfo formatInfo = new SpeechAudioFormatInfo(16000, AudioBitsPerSample.Sixteen, Microsoft.Speech.AudioFormat.AudioChannel.Mono);
                SpeechSynthesisConnector connector = new SpeechSynthesisConnector();

                synth.SetOutputToAudioStream(connector.Stream, formatInfo);

                connector.AttachFlow(flow);
                connector.Start();

                synth.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(
                    (sender, args) =>
                    {
                        connector.Stop();
                        synth.Dispose();
                    });

                synth.SpeakAsync(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to play the message. {0}", ex);
            }

        }
开发者ID:hhqqnu,项目名称:MSLyncProjects,代码行数:28,代码来源:AVCallHelper.cs

示例5: speak

 public void speak(string word)
 {
     try
     {
         SpeechSynthesizer voice = new SpeechSynthesizer();
         switch (cmbbox.SelectedIndex)
         {
             case 0:
                 voice.SelectVoiceByHints(VoiceGender.NotSet);
                 break;
             case 1:
                 voice.SelectVoiceByHints(VoiceGender.Male);
                 break;
             case 2:
                 voice.SelectVoiceByHints(VoiceGender.Female);
                 break;
             case 3:
                 voice.SelectVoiceByHints(VoiceGender.Neutral);
                 break;
             default:
                 voice.SelectVoiceByHints(VoiceGender.NotSet);
                 break;
         }
         voice.SpeakAsync(word);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
开发者ID:AhmedShaabanElhdad,项目名称:Vocabulary,代码行数:30,代码来源:Form1.cs

示例6: LoadList

        private void LoadList()
        {
            EUser  c = new EUser();
            DataSet ds = c.GetListSpecific(txtUserName.Text,txtPassword.Text,Convert.ToInt32(cbxRole.SelectedValue));
            if (ds.Tables[0].Rows.Count > 0)
            {
                
                

                frmMain frm = new frmMain();
                
                frm.curruserid = Convert.ToInt32(ds.Tables[0].Rows[0]["UID"]);
                
                frm.currusername = txtUserName.Text;
                frm.pwd = txtPassword.Text;
                frm.role = cbxRole.Text;
                MISCurrentSettings.curruid = Convert.ToInt32(ds.Tables[0].Rows[0]["UID"]);
                frm.Show();
                this.Hide();
               
            }
            else
            {
               SpeechSynthesizer  ss = new SpeechSynthesizer();
               // MessageBox.Show("Sorry Your Login Information not Valid, Try Again");
                ttp.Show("Sorry Your Login Information not Valid, Please Try Again", txtPassword, 3000);
                ss.SpeakAsync("Sorry Your Login Information not Valid, Please Try Again");
               
            }

            
        }
开发者ID:yasarmalik,项目名称:AQSMS,代码行数:32,代码来源:frmLogin.cs

示例7: TextToSpeechDecal

        public TextToSpeechDecal()
        {
            MetaData = new AudioMetaData();
            CanResize = false;
            Stretch = System.Windows.Media.Stretch.None;
            Center = new System.Windows.Point(0.5,1);
            PinPoint = new System.Windows.Point(0.5,1);
            CanMove = false;

            #if !SILVERLIGHT
            Play = new DelegateCommand(() =>
            {
                if (!string.IsNullOrEmpty(MetaData.Source) && !_isSpeaking)
                {
                    synthesizer = new SpeechSynthesizer();
                    synthesizer.Rate = -1;

                    synthesizer.SpeakAsync(MetaData.Source);
                    _isSpeaking = true;
                    // always dispose resources!
                    synthesizer.SpeakCompleted += new EventHandler<System.Speech.Synthesis.SpeakCompletedEventArgs>(task_SpeakCompleted);
                }
            }, () =>
            {
                return !string.IsNullOrEmpty(MetaData.Source);
            });
            #endif
        }
开发者ID:luiseduardohdbackup,项目名称:dotnet-1,代码行数:28,代码来源:TextToSpeechDecal.cs

示例8: Play

 public void Play()
 {
     speaker = new SpeechSynthesizer();
     speaker.SelectVoice("ScanSoft Raquel_Full_22kHz");
     speaker.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(speaker_SpeakCompleted);
     speaker.SpeakAsync(texto);
     speaker.Resume();
 }
开发者ID:vanderleiarruda,项目名称:aturtes,代码行数:8,代码来源:BFala.cs

示例9: 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

示例10: TextToSpeech

 public static void TextToSpeech(string say, int rate)
 {
     using (SpeechSynthesizer sapi = new SpeechSynthesizer())
     {
         sapi.Volume = 100;
         sapi.Rate = rate;
         sapi.SpeakAsync(say);
     }
 }
开发者ID:BahNahNah,项目名称:MLRat,代码行数:9,代码来源:MiscHandler.cs

示例11: btnVoice_Click

        protected void btnVoice_Click(object sender, EventArgs e)
        {
            // creating the object of SpeechSynthesizer class
            SpeechSynthesizer sp = new SpeechSynthesizer();
            //setting volume
            sp.Volume = 100;
            //passing text box text to SpeakAsync method

            string text = txtMsg.Text;
            sp.SpeakAsync(text);
        }
开发者ID:AshokYaganti,项目名称:ASE-Project,代码行数:11,代码来源:Default.aspx.cs

示例12: Main

 static void Main(string[] args)
 {
     Console.WriteLine("Enter text to speak:");
     string TextToSpeak = Console.ReadLine(); 
     SpeechSynthesizer ss = new SpeechSynthesizer();
     ss.Volume = 100; //1 to 100
     ss.Rate = -3; // -10 to +10 
     ss.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Child);
     ss.SpeakAsync(TextToSpeak); 
     Console.Read();
 }
开发者ID:ananth039,项目名称:Anantha-Kumar-.net-Practice-programs,代码行数:11,代码来源:Program.cs

示例13: btnSpeak_Click

 private void btnSpeak_Click(object sender, EventArgs e)
 {
     if (rtxtSpeak.Text != "")
     {
         reader.Dispose();
         reader = new SpeechSynthesizer();
         reader.SpeakAsync(rtxtSpeak.Text);
     }
     else
     {
         MessageBox.Show(@"Type in the textbox");
     }
 }
开发者ID:Mortion,项目名称:Uses,代码行数:13,代码来源:MainForm.cs

示例14: btnRead_Click

 public void btnRead_Click(object sender, EventArgs e)
 {
     // Message if there is no text in the text box
     if (string.IsNullOrEmpty(rtxtInput.Text))
     {
         Monica.SpeakAsync("Sorry,  I can't read without text, Enter text first");
     }
     else
     {
         Monica.Dispose();
         Monica = new SpeechSynthesizer();
         Monica.SpeakAsync(rtxtInput.Text); // print the text in text box
     }
 }
开发者ID:Kabouterhuisje,项目名称:Voice_Recognition_App,代码行数:14,代码来源:Form1.cs

示例15: MessageBoxWindow_OnLoaded

 private void MessageBoxWindow_OnLoaded(object sender, RoutedEventArgs e)
 {
     var voice = new SpeechSynthesizer();
     try
     {
         voice.Volume = 100;
         voice.Rate = 0;
         voice.SpeakAsync(TxtMessage.Text);
     }
     catch (Exception ex)
     {
         Log.ErrorLog(ex);
     }
 }
开发者ID:prabash,项目名称:Voice-Based-Web-Browser,代码行数:14,代码来源:MessageBoxWindow.xaml.cs


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