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); }
public static void SpeakAsync(string content) { Dispose(); synth = new System.Speech.Synthesis.SpeechSynthesizer(); synth.SpeakAsyncCancelAll(); synth.SpeakAsync(content);//异步朗读 }
public void SpeakVoice(string words) { //C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0 System.Speech.Synthesis.SpeechSynthesizer mVoiceSpeaker = new System.Speech.Synthesis.SpeechSynthesizer(); mVoiceSpeaker.SpeakAsync(words); //mVoiceSpeaker.Speak(words); }
public void DoSpeak(string aValue, int aSpeakOption, bool aAsync) { try { bool DesktopMode = PlayniteApi.ApplicationInfo.Mode == ApplicationMode.Desktop; bool DoPlay = ((DesktopMode && ((aSpeakOption == 1) || (aSpeakOption == 3))) || (!DesktopMode && ((aSpeakOption == 2) || (aSpeakOption == 3)))); if (DoPlay && (aValue.Length > 0)) { Speak.SpeakAsyncCancelAll(); if (aAsync) { Speak.SpeakAsync(aValue); } else { Speak.Speak(aValue); } } } catch (Exception E) { logger.Error(E, "DoSpeak"); PlayniteApi.Dialogs.ShowErrorMessage(E.ToString(), Constants.AppName); } }
private void Read() { if (ssz == null) { ssz = new System.Speech.Synthesis.SpeechSynthesizer(); ssz.SpeakCompleted += (sender, e) => { if (rindex + 1 < BookInfo.Sentenses.Length) { rindex++; ssz.SpeakAsync(BookInfo.Sentenses[rindex]); } else { ssz.Pause(); } }; ssz.Volume = 100; } if (ssz.State == System.Speech.Synthesis.SynthesizerState.Paused) { ssz.Resume(); return; } if (ssz.State == System.Speech.Synthesis.SynthesizerState.Speaking) { return; } if (BookInfo.Sentenses != null && BookInfo.Sentenses.Length > 0) { ssz.SpeakAsync(BookInfo.Sentenses[rindex]); } }
public static void sayt(string dhjgf) { System.Speech.Synthesis.SpeechSynthesizer syh = new System.Speech.Synthesis.SpeechSynthesizer(); syh.SpeakAsync(dhjgf); }
public static void sayt(string h) { try { Console.WriteLine(h); saytd.SelectVoice("Microsoft Hortense Desktop"); saytd.SpeakAsync(h); } catch { } }
/// <summary> /// 説明文ダブルクリック時 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TextBoxDescription_DoubleClick(object sender, EventArgs e) { // まだ読み上げてなければ、説明文を読み上げ if (!IsSpeaking && (Synthesizer != null)) { Synthesizer.SpeakAsyncCancelAll(); Synthesizer.SpeakAsync(this.textBoxDescription.Text); IsSpeaking = true; } }
public static QsValue Speak( [QsParamInfo(QsParamType.Text)] QsParameter text ) { System.Speech.Synthesis.SpeechSynthesizer ss = new System.Speech.Synthesis.SpeechSynthesizer(); ss.SpeakAsync(text.UnknownValueText); return(null); }
static void Main() { var info = new ProcessStartInfo(@"C:\utilities\MakeMsi\MM.CMD", "ConEdit.MM"); info.WorkingDirectory = "."; System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer(); Process p = Process.Start(info); var wait = synth.SpeakAsync("Launching the process now"); p.WaitForExit(); }
void _cmdPlay_Click(object sender, EventArgs e) { ss = new System.Speech.Synthesis.SpeechSynthesizer(); ss.Volume = _volume; ss.Rate = _rate; if (_OnTextToSpeechNeeded != null) { _SourceText = _OnTextToSpeechNeeded(); } ss.SpeakAsync(_SourceText); }
public override void Speak(string text, bool gender, int ipitch) { var Synth = new System.Speech.Synthesis.SpeechSynthesizer(); Synth.SelectVoiceByHints((gender) ? System.Speech.Synthesis.VoiceGender.Female : System.Speech.Synthesis.VoiceGender.Male); if (text == "") { return; } var voci = Synth.GetInstalledVoices(); var stream = new System.IO.MemoryStream(); var pitch = Math.Max(0.1f, ipitch / 100f + 1f); //below 0.1 is just stupid, so just clamp there. if (pitch < 1f) { Synth.Rate = 10 - (int)(pitch * 10); } else { Synth.Rate = (int)(10 / pitch) - 10; } Synth.SetOutputToWaveStream(stream); Synth.SpeakAsync(text); EventHandler <System.Speech.Synthesis.SpeakCompletedEventArgs> OnComplete = null; OnComplete = (obj, evt) => { GameThread.NextUpdate((u) => { stream.Seek(0, System.IO.SeekOrigin.Begin); var sfx = SoundEffect.FromStream(stream); var inst = sfx.CreateInstance(); inst.Pitch = pitch - 1f; inst.Play(); GameThreadInterval interval = null; interval = GameThread.SetInterval(() => { if (inst.State == SoundState.Stopped) { sfx.Dispose(); //just catch and dispose these when appropriate interval.Clear(); } }, 1000); Synth.Dispose(); }); Synth.SpeakCompleted -= OnComplete; }; Synth.SpeakCompleted += OnComplete; }
public static void Speak(string text, bool cancel, bool local, Func <string, string> TTSReplace) { TTS.Rate = -5; Console.WriteLine("\tTTS: " + text); if (cancel) { TTS.SpeakAsyncCancelAll(); } if (text.Trim().Length > 0) { TTS.SpeakAsync(TTSReplace != null ? TTSReplace(text) : text); } }
public void GetWeather() { say.SelectVoice("Microsoft Hortense Desktop"); var path = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22saguenay%22)%20and%20u%3D%22c%22&format=xml&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"; var doc = XDocument.Load(path); XNamespace ns = "http://xml.weather.yahoo.com/ns/rss/1.0"; var results = (from i in doc.Descendants(ns + "condition") select i); foreach (var thisResult in results) { Console.WriteLine("la temperature {0} pour dehors et il fait {1}", thisResult.Attribute("temp").Value, thisResult.Attribute("text").Value); say.SpeakAsync(string.Format("la temperature {0} pour dehors et il fait {1}", thisResult.Attribute("temp").Value, thisResult.Attribute("text").Value)); } }
private void AudioStoppedCanSay(object sender, AudioStateChangedEventArgs e) { Task.Delay(10).ContinueWith((o) => { var speak = _synthesizer.SpeakAsync(_messageToSay); while (!speak.IsCompleted) { System.Threading.Thread.Sleep(50); } _recognitionEngine.AudioStateChanged -= AudioStoppedCanSay; _recognitionEngine.RecognizeAsync(RecognizeMode.Multiple); }); }
private void Say(string Statement) { string wavFile = GetWavFileForText(Statement); if ((wavFile != String.Empty) && (System.IO.File.Exists(wavFile))) { PlayWavFile(wavFile); // using (SoundPlayer player = new SoundPlayer(wavFile)) // player.Play(); } else { synth.SpeakAsync(Statement); } }
private void tmrRepeat_Tick(object sender, EventArgs e) { tmrRepeat.Enabled = false; btnReminder.Text = reminderText; #if USE_SYSTEM_SPEECH tts.SpeakAsync(reminderText); #else try { voice.Speak(reminderText, SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); } catch (Exception err) { System.Diagnostics.EventLog.WriteEntry("Clock tmrRepeat_Tick", "Error using SAPI5 through COM: " + err.Message); } #endif }
private void Speak(string s) { #if USE_SYSTEM_SPEECH System.Speech.Synthesis.SpeechSynthesizer tts = new System.Speech.Synthesis.SpeechSynthesizer(); tts.SpeakAsync(textTime.Text); #else try { SpeechLib.SpVoice voice = new SpeechLib.SpVoice(); voice.Speak(s, SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); } catch (Exception err) { System.Diagnostics.EventLog.WriteEntry("Clock", "Failed to use SAPI5 through COM: " + err.Message); } #endif }
private void timer1_Tick(object sender, EventArgs e) { var kg = DateTime.Now; label2.Text = kg.ToString("dd.MM"); label1.Text = kg.ToString("HH.mm"); if (comboBox1.Items.Contains(label2.Text + label1.Text)) { if (File.Exists(label2.Text + label1.Text + ".txt")) { hj++; var fty = File.ReadAllText(label2.Text + label1.Text + ".txt"); if (hj <= 1) { kn.SpeakAsync("alarm alarm un alarm a été detecter regarde le rappel important inscrit dans lagenda alarm alarm alarm alarm alarm un alarm a été detecter regarde le rappel important inscrit dans lagenda alarm alarm alarm"); MessageBox.Show("RAPPEL .il est " + label1.Text + " et " + fty); } } } }
public Form1() { InitializeComponent(); if (!File.Exists("execombo.tx")) { File.WriteAllText("execombo.tx", ""); } if (!File.Exists("execombo2.tx")) { File.WriteAllText("execombo2.tx", ""); } Application.DoEvents(); Thread.Sleep(0); comboBox1.Items.Clear(); setdir = Directory.GetCurrentDirectory(); string[] dpf = File.ReadAllLines("execombo2.tx"); dfdg = dpf.Distinct(); foreach (string fjf in dfdg) { try { if (fjf.Contains("vshost")) { } else { string dhf = Path.GetPathRoot(fjf); string fhjg = Path.GetFileName(dhf + fjf); comboBox1.Items.Add(dhf + fhjg); } } catch { } } Application.DoEvents(); Thread.Sleep(0); say.SpeakAsync("it is good all done"); }
public void SpeakAsync(string msg, int volume = 50) { System.Speech.Synthesis.SpeechSynthesizer speechSynthesizer = new System.Speech.Synthesis.SpeechSynthesizer(); speechSynthesizer.Volume = volume; speechSynthesizer.SpeakAsync(msg); }
public void commandlist() { holdtext = holdtext + Environment.NewLine; holdtext = holdtext + "EggmanOS status: "; if (commandstring == "help") { holdtext += "There is no help, just type in stuff"; commandstring = ""; } else if (commandstring == "log") { for (int i = 0; i <= Eggkernel.log.Count; i++) { try { holdtext = holdtext + Environment.NewLine + Eggkernel.log[i]; } catch { } } commandstring = ""; } else if (commandstring.StartsWith("print")) { Commandegg.Text = holdtext; Print(commandstring.Remove(0, 5), 100); commandstring = ""; } else if (commandstring.StartsWith("cmd ")) { Commandegg.Text = holdtext; ProcessStartInfo command = new ProcessStartInfo("cmd"); command.UseShellExecute = false; command.RedirectStandardOutput = true; command.CreateNoWindow = true; command.RedirectStandardInput = true; Process pro = Process.Start(command); pro.StandardInput.WriteLine(commandstring.Remove(0, 4)); pro.StandardInput.WriteLine("exit"); holdtext += pro.StandardOutput.ReadToEnd(); commandstring = ""; } else if (commandstring == "shutdown") { Installer.Endgame(); } else if (commandstring == "projectegg") { if (!projecteggactive) { holdtext += "Loading old Eggman Window Environment Manager"; Powereggman power = new Powereggman(); power.Show(); projecteggactive = true; Commandegg.Hide(); } } else if (commandstring.StartsWith("Speak ")) { System.Speech.Synthesis.SpeechSynthesizer speak = new System.Speech.Synthesis.SpeechSynthesizer(); speak.SpeakAsync(commandstring.Remove(0,5)); //Process.Start(Eggkernel.eggsys32folder + "EggmanPlayer.exe"); } else { holdtext += "The command \"" + commandstring + "\" does not have any meaning. " + Environment.NewLine + "If this command is a name of a script, please install it"; } holdtext = holdtext + Environment.NewLine + Eggkernel.username + "$>"; Commandegg.Text = holdtext; commandstring = ""; }
public string GetDirectionDiscriptionFromLocation(LatLng loc) { int index = GetNearestPolyIndex(loc); if (index < 0) { string Description = "You've lost your way!!!!"; if (!isLostWay) { #if SPEECH_ENABLED speaker.SpeakAsync(Description); #endif isLostWay = true; } return(Description); } else { DirectionStep step = GetDirectionNextStep(index); isLostWay = false; if (step != null) { double distance = CalculateDistanceOfNextStep(loc, index, step); string str_dis; if (distance < 1) { str_dis = " in " + String.Format("{0:0}", distance * 1000) + " Meters"; } else { str_dis = " in " + String.Format("{0:0.0}", distance) + " KiloMeters"; } string Description = step.step_description + str_dis; if (!step.far_speech) { #if SPEECH_ENABLED speaker.SpeakAsync(Description); #endif if (distance * 1000 < 300) { step.near_speech = true; } step.far_speech = true; } if (distance * 1000 < 300 && step.near_speech == false) { step.near_speech = true; #if SPEECH_ENABLED speaker.SpeakAsync(Description); #endif } return(Description); } else { isLostWay = true; double distance = util.GetDistanceBetweenPoints(loc, Points[Points.Count - 1]); string str_dis; if (distance < 1) { str_dis = "in " + String.Format("{0:0}", distance * 1000) + " Meters"; } else { str_dis = "in " + String.Format("{0:0.0}", distance) + " KiloMeters"; } string Description = "Arrive " + str_dis; if (distance * 1000 < 500) { if (!isArrived) { #if SPEECH_ENABLED speaker.SpeakAsync(Description); #endif } } isArrived = true; return(Description); } } }
private void CallBack(Object source, System.Timers.ElapsedEventArgs e) { cat.SpeakAsync("Meow"); }
private void listBox1_Click(object sender, EventArgs e) { synthesizer.SpeakAsync(listBox1.SelectedItem.ToString()); }
public override void HandleTrigger(TriggerInput _Input) { var sam = new System.Speech.Synthesis.SpeechSynthesizer(); sam.SpeakAsync(text); }
private void skype_Load(object sender, EventArgs e) { try { this.Text = "SKYPE"; this.webBrowser1.ScriptErrorsSuppressed = true; webBrowser1.ObjectForScripting = true; if (textBox1.Text != "") { webBrowser1.Navigate(textBox1.Text); } webBrowser1.ProgressChanged += new WebBrowserProgressChangedEventHandler(webpage_ProgressChanged); webBrowser1.DocumentTitleChanged += new EventHandler(webpage_DocumentTitleChanged); webBrowser1.StatusTextChanged += new EventHandler(webpage_StatusTextChanged); webBrowser1.Navigated += new WebBrowserNavigatedEventHandler(webpage_Navigated); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webpage_DocumentCompleted); webBrowser1.Navigate(skypconsol.Properties.Settings.Default.skype1); say.SpeakAsync("skype loading"); } catch { } }
public override void Speak(string text, bool gender) { Synth.SelectVoiceByHints((gender) ? System.Speech.Synthesis.VoiceGender.Female : System.Speech.Synthesis.VoiceGender.Male); Synth.SpeakAsync(text); }
/// <summary>异步调用语音引擎说出指定话。可能导致后来的调用打断前面的语音</summary> /// <param name="value"></param> public static void SpeakAsync(this String value) { Init(); _provider.SpeakAsync(value); }
public static void sayt(string hdgf) { System.Speech.Synthesis.SpeechSynthesizer skdf = new System.Speech.Synthesis.SpeechSynthesizer(); skdf.SelectVoice("Microsoft Hortense Desktop"); skdf.SpeakAsync(hdgf); }
private bool SynthesizeAudio(string outputFile, bool isSsml, string text) { if (this.synthesizerType == "Windows") { using var synth = new System.Speech.Synthesis.SpeechSynthesizer(); try { synth.InjectOneCoreVoices(); } catch { } synth.Rate = rate; synth.Volume = volume; synth.SetOutputToWaveFile(outputFile); finished = false; failed = false; synth.SpeakCompleted += OnSpeakCompleted; if (isSsml) { synth.SpeakSsmlAsync(text); } else { synth.SpeakAsync(text); } while (!finished) { Thread.Sleep(100); } return(true); } else { RenewToken(); using var audioConfig = AudioConfig.FromWavFileOutput(outputFile); using var synthesizer = new Microsoft.CognitiveServices.Speech.SpeechSynthesizer(config, audioConfig); finished = false; failed = false; synthesizer.SynthesisCanceled += OnSynthesisCanceled; synthesizer.SynthesisCompleted += OnSynthesisCompleted; if (isSsml) { synthesizer.SpeakSsmlAsync(text); } else { synthesizer.SpeakTextAsync(text); } while (!finished) { Thread.Sleep(100); } return(!failed); } }