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);
     }
 }
Beispiel #2
0
 private void OkButton_Click(object sender, EventArgs e)
 {
     if (IsSpeaking && (Synthesizer != null))
     {
         Synthesizer.SpeakAsyncCancelAll();
     }
     IsSpeaking = false;
 }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
 public static void SpeakAsync(string content)
 {
     Dispose();
     synth = new System.Speech.Synthesis.SpeechSynthesizer();
     synth.SpeakAsyncCancelAll();
     synth.SpeakAsync(content);//异步朗读
 }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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();
        }