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 OkButton_Click(object sender, EventArgs e) { if (IsSpeaking && (Synthesizer != null)) { Synthesizer.SpeakAsyncCancelAll(); } IsSpeaking = false; }
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 static void SpeakAsync(string content) { Dispose(); synth = new System.Speech.Synthesis.SpeechSynthesizer(); synth.SpeakAsyncCancelAll(); synth.SpeakAsync(content);//异步朗读 }
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); }
private void btnReminder_Click(object sender, EventArgs e) { tmrRepeat.Enabled = false; #if USE_SYSTEM_SPEECH tts.SpeakAsyncCancelAll(); #else try { voice.Speak("", SpeechLib.SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); } catch { // SAPI5 problem. Catch when object instantiated or used earlier. } #endif Application.DoEvents(); this.Close(); }