コード例 #1
0
 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);
     }
 }
コード例 #2
0
 private void OkButton_Click(object sender, EventArgs e)
 {
     if (IsSpeaking && (Synthesizer != null))
     {
         Synthesizer.SpeakAsyncCancelAll();
     }
     IsSpeaking = false;
 }
コード例 #3
0
ファイル: AuditSec.cs プロジェクト: viiinzzz/AuditSec
 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);
     }
 }
コード例 #4
0
 public static void SpeakAsync(string content)
 {
     Dispose();
     synth = new System.Speech.Synthesis.SpeechSynthesizer();
     synth.SpeakAsyncCancelAll();
     synth.SpeakAsync(content);//异步朗读
 }
コード例 #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);
        }
コード例 #6
0
ファイル: frmReminder.cs プロジェクト: AlasdairKing/Clock
        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();
        }