本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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");
}
}
示例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
}
示例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();
}
示例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);
}
示例10: TextToSpeech
public static void TextToSpeech(string say, int rate)
{
using (SpeechSynthesizer sapi = new SpeechSynthesizer())
{
sapi.Volume = 100;
sapi.Rate = rate;
sapi.SpeakAsync(say);
}
}
示例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);
}
示例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();
}
示例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");
}
}
示例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
}
}
示例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);
}
}