private void SpeakButton_Click(object sender, EventArgs e) { StatusTextBox.Text = ""; var promptBuilder = new System.Speech.Synthesis.PromptBuilder(); promptBuilder.AppendText(MessageTextBox.Text); var client = new Voices.AmazonPolly( SettingsManager.Options.AmazonAccessKey, SettingsManager.Options.AmazonSecretKey, SettingsManager.Options.AmazonRegionSystemName ); var voice = (Voice)((InstalledVoiceEx)VoicesComboBox.SelectedItem).Voice; Amazon.Polly.Engine engine = null; if (voice.SupportedEngines.Contains(Amazon.Polly.Engine.Neural)) { engine = Amazon.Polly.Engine.Neural; } var buffer = client.SynthesizeSpeech(voice.Id, promptBuilder.ToXml(), null, engine); var result = client.LastException == null ? "Success" : client.LastException.Message; StatusTextBox.Text = string.Format("{0:HH:mm:ss}: {1}", DateTime.Now, result); var item = Global.DecodeToPlayItem(buffer); Global.playlist.Add(item); }
private static void Say(System.Globalization.CultureInfo culture, string text) { var prompt = new System.Speech.Synthesis.PromptBuilder(culture); prompt.StartSentence(); prompt.AppendText(text); prompt.EndSentence(); speech.SpeakAsync(prompt); }
private static void Say(string text) { if (speech.State == System.Speech.Synthesis.SynthesizerState.Speaking) { speech.SpeakAsyncCancelAll(); } var prompt = new System.Speech.Synthesis.PromptBuilder(); prompt.StartSentence(); prompt.AppendText(text); prompt.EndSentence(); speech.SpeakAsync(prompt); }