Пример #1
1
        private static byte[] StartSpeak(string word)
        {
            var ms = new MemoryStream();
            using (System.Speech.Synthesis.SpeechSynthesizer synhesizer = new System.Speech.Synthesis.SpeechSynthesizer())
            {
                foreach (var voice in synhesizer.GetInstalledVoices())
                {
                    Console.WriteLine("select(y/n): " + voice.VoiceInfo.Name);
                    var key = Console.ReadKey();
                    if (key.Key == ConsoleKey.Y)
                    {
                        synhesizer.SelectVoice(voice.VoiceInfo.Name);
                        synhesizer.SelectVoiceByHints(voice.VoiceInfo.Gender, voice.VoiceInfo.Age, 1, voice.VoiceInfo.Culture);
                        synhesizer.SetOutputToWaveStream(ms);
                        synhesizer.Speak(word);
                    }
                }
            }

            return ms.ToArray();
        }
Пример #2
0
        static void Main(string[] args)
        {
            var syn = new System.Speech.Synthesis.SpeechSynthesizer();

            syn.SelectVoice("Microsoft Server Speech Text to Speech Voice (ja-JP, Haruka)");
            syn.Speak("こんにちは");
        }
Пример #3
0
 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]);
     }
 }
Пример #4
0
        public string GetVoices()
        {
            if (this.synthesizerType == "Azure")
            {
                RenewToken();

                return(SynthesisGetAvailableVoicesAsync().Result);
            }
            else
            {
                using var synth = new System.Speech.Synthesis.SpeechSynthesizer();

                try {
                    synth.InjectOneCoreVoices();
                }
                catch {
                }

                string voices = "";

                foreach (var voice in synth.GetInstalledVoices())
                {
                    if (voices.Length > 0)
                    {
                        voices += "|";
                    }

                    voices += voice.VoiceInfo.Name + " (" + voice.VoiceInfo.Culture.Name + ")";
                }

                return(voices);
            }
        }
Пример #5
0
 public byte[] SpeakContentStream(string content)
 {
     byte[] buffer = CacheHelper.Get(content) as byte[];
     if (buffer != null)
     {
         return(buffer);
     }
     else
     {
         using (System.Speech.Synthesis.SpeechSynthesizer speechSyn = new System.Speech.Synthesis.SpeechSynthesizer())
         {
             speechSyn.Volume = 100;
             speechSyn.Rate   = 0;
             using (var ms = new System.IO.MemoryStream())
             {
                 speechSyn.SetOutputToWaveStream(ms);
                 speechSyn.Speak(content);
                 speechSyn.SetOutputToNull();
                 buffer = ms.ToArray();
                 //设置平滑过期
                 CacheHelper.Set(content, buffer, TimeSpan.FromSeconds(30));
                 return(buffer);
             }
         }
     }
 }
Пример #6
0
 public static void SpeakAsync(string content)
 {
     Dispose();
     synth = new System.Speech.Synthesis.SpeechSynthesizer();
     synth.SpeakAsyncCancelAll();
     synth.SpeakAsync(content);//异步朗读
 }
Пример #7
0
        static void Main(string[] args)
        {
            var speak = new System.Speech.Synthesis.SpeechSynthesizer();

            speak.Rate = 0;
            speak.Speak("Never gonna give you up Never gonna let you down Never gonna run around and desert you");
        }
Пример #8
0
        private void AlarmControlTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                TimeSpan TimeRest = default;
                if (AlarmClockTime.TimeOfDay < DateTime.Now.TimeOfDay)
                {
                    RunningTime -= TimeSpan.FromMilliseconds(1000);
                    TimeRest    -= RunningTime;
                }
                else
                {
                    TimeRest = AlarmClockTime - DateTime.Now;
                }

                AlarmControlLabel.Text = $"{Math.Abs(TimeRest.Hours)}" +
                                         $"H:{Math.Abs(TimeRest.Minutes)}" +
                                         $"M:{Math.Abs(TimeRest.Seconds)}S";

                if (TimeRest.Hours == 0 && TimeRest.Minutes == 0 && TimeRest.Seconds == 0)
                {
                    var Thread = new System.Threading.Thread(() =>
                    {
                        using (Speech = new System.Speech.Synthesis.SpeechSynthesizer())
                        {
                            Speech.Volume = 100;

                            int i = 0;
                            while (Speech != null && i++ != 10)
                            {
                                Speech?.Speak("Get up, leather bag, time to work");
                            }

                            this.Invoke((System.Action) delegate()
                            {
                                AlarmControlTimer.Enabled = false;
                                Speech = null;
                                AlarmControlInputTimeTextBox.Text = "";
                                AlarmControlLabel.Text            = "00H:00M:00S";
                            });
                        }
                    });

                    Thread.IsBackground = true;
                    Thread.Start();

                    if (Thread.IsAlive)
                    {
                        AlarmControlTimer.Enabled = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(),
                                ex.GetType().Name,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Пример #9
0
 private void AlarmControlStopButton_Click(object sender, EventArgs e)
 {
     AlarmControlTimer.Enabled = false;
     Speech = null;
     AlarmControlInputTimeTextBox.Text = "";
     AlarmControlLabel.Text            = "00H:00M:00S";
 }
Пример #10
0
        private void speakAll()
        {
            synthesizer = new System.Speech.Synthesis.SpeechSynthesizer();
            CultureInfo culture = new CultureInfo("en-US");

            synthesizer.SelectVoiceByHints(System.Speech.Synthesis.VoiceGender.Female, System.Speech.Synthesis.VoiceAge.Teen, 1, culture);

            List <string> lis = new List <string>(174);

            foreach (var it in colorsArray)
            {
                lis.Add(colorsArray.ToString());
            }
            // System.Threading.Thread.Sleep(20000);
            Random random = new Random();
            int    item   = 0;
            int    count  = lis.Count;

            for (int i = 0; i <= count; i++)
            {
                item = random.Next(0, lis.Count);
                synthesizer.Speak(lis[item]);
                lis.Remove(lis[item]);
            }
        }
Пример #11
0
        private static void ProcessMessage(IMail email)
        {
            Console.WriteLine("Subject: " + email.Subject);
            Console.WriteLine("From: " + JoinAddresses(email.From));
            Console.WriteLine("To: " + JoinAddresses(email.To));
            Console.WriteLine("Cc: " + JoinAddresses(email.Cc));
            Console.WriteLine("Bcc: " + JoinAddresses(email.Bcc));

            Console.WriteLine("Text: " + email.Text);
            Console.WriteLine("HTML: " + email.Html);
            System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer();

            synth.SetOutputToDefaultAudioDevice();

            // Speak a string.
            synth.Speak("You have a Mail from" + email.From + "On" + email.Subject + email.Text);

            Console.WriteLine();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();

            Console.WriteLine("Attachments: ");
            foreach (MimeData attachment in email.Attachments)
            {
                Console.WriteLine(attachment.FileName);
                attachment.Save(@"c:\" + attachment.SafeFileName);
            }
        }
Пример #12
0
 public static void Speak(string msg, int rate, int vol)
 {
     System.Speech.Synthesis.SpeechSynthesizer ss = new System.Speech.Synthesis.SpeechSynthesizer();
     ss.Rate   = rate;
     ss.Volume = vol;
     ss.Speak(msg);
 }
Пример #13
0
        static void Main()
        {
            using (Imap imap = new Imap())
            {
                imap.ConnectSSL(_server);                        // Use overloads or ConnectSSL if you need to specify different port or SSL.
                imap.Login(_user, _password);                    // You can also use: LoginPLAIN, LoginCRAM, LoginDIGEST, LoginOAUTH methods,
                                                                 // or use UseBestLogin method if you want Mail.dll to choose for you.

                imap.SelectInbox();                              // You can select other folders, e.g. Sent folder: imap.Select("Sent");

                List <long> uids = imap.Search(Flag.Unseen);     // Find all unseen messages.

                Console.WriteLine("Number of unseen messages is: " + uids.Count);
                System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer();

                synth.SetOutputToDefaultAudioDevice();
                String speak = "you have" + uids.Count.ToString();
                // Speak a string.
                synth.Speak(speak);

                foreach (long uid in uids)
                {
                    IMail email = new MailBuilder().CreateFromEml(  // Download and parse each message.
                        imap.GetMessageByUID(uid));

                    ProcessMessage(email);                          // Display email data, save attachments.
                }
                imap.Close();
            }
        }
 public WindowsSpeechEngine()
 {
     synth = new System.Speech.Synthesis.SpeechSynthesizer();
     synth.SetOutputToDefaultAudioDevice();
     synth.SpeakCompleted += (s, e) => SpeakingCompleted?.Invoke(s, e);
     systemdefaultvoice    = synth.Voice.Name;
 }
Пример #15
0
        public static void sayt(string dhjgf)
        {
            System.Speech.Synthesis.SpeechSynthesizer syh = new System.Speech.Synthesis.SpeechSynthesizer();


            syh.SpeakAsync(dhjgf);
        }
Пример #16
0
        protected override void Execute(CodeActivityContext context)
        {
            var voice   = Voice.Get(context);
            var rate    = Rate.Get(context);
            var volume  = Volume.Get(context);
            var doasync = Async.Get(context);
            var text    = Text.Get(context);
            var task    = Task.Run(() =>
            {
                using (var synthesizer = new System.Speech.Synthesis.SpeechSynthesizer())
                {
                    if (!string.IsNullOrEmpty(voice))
                    {
                        synthesizer.SelectVoice(voice);
                    }
                    if (rate >= 1 && rate <= 10)
                    {
                        synthesizer.Rate = rate;
                    }
                    if (volume >= 1 && volume <= 100)
                    {
                        synthesizer.Volume = volume;
                    }
                    synthesizer.SetOutputToDefaultAudioDevice();
                    synthesizer.Speak(text);
                }
            });

            if (!doasync)
            {
                task.Wait();
            }
        }
Пример #17
0
        public List <string> getSystemVoices()
        {
            List <string> voices = new List <string> ();

                        #if __WIN32__
            using (var speech = new SpeechEngine()) {
                var voicelist = speech.GetInstalledVoices();
                foreach (InstalledVoice v in voicelist)
                {
                    if (v.Enabled)
                    {
                        Console.WriteLine(v.VoiceInfo.Name);
                        voices.Add(v.VoiceInfo.Name);
                    }
                }
            }
                        #else
            NSApplication.SharedApplication.InvokeOnMainThread(() => {
                foreach (var voice in SpeechEngine.AvailableVoices)
                {
                    voices.Add(voice);
                }
            });
                        #endif

            return(voices);
        }
Пример #18
0
 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);
 }
Пример #19
0
 public static void Speak(string msg)
 {
     System.Speech.Synthesis.SpeechSynthesizer ss = new System.Speech.Synthesis.SpeechSynthesizer();
     ss.Rate   = 3;
     ss.Volume = 100;
     ss.Speak(msg);
 }
Пример #20
0
        public TerminalControl(COMMON.DataEvent main_event, BOL.Terminal.objTerminal terminal, BOL.Display_Settings.objDisplaySettings display_setting)
        {
            InitializeComponent();

            this.Width  = display_setting.terminal_width;
            this.Height = display_setting.terminal_height;
            this.TerminalTitle.FontSize  = display_setting.terminal_name_fontsize;
            this.lblQueueNumber.FontSize = display_setting.queue_number_fontsize;
            this.Voice = new System.Speech.Synthesis.SpeechSynthesizer()
            {
                Volume = 100
            };
            this.MainEvent       = main_event;
            this.Terminal        = terminal;
            this.DefaultFontsize = lblQueueNumber.FontSize;
            this.Timer           = new System.Windows.Threading.DispatcherTimer()
            {
                Interval = new TimeSpan(0, 0, 1)
            };
            this.NotificationSound        = new SoundPlayer(Properties.Resources.doorbell_sound);
            this.Timer.Tick              += Timer_Tick;
            this.MainEvent.OnDataConfirm += MainEvent_OnDataConfirm;

            Initialize_Window();
        }
Пример #21
0
        private void listBox1_DoubleClick(object sender, EventArgs e)
        {
            synthesizer = new System.Speech.Synthesis.SpeechSynthesizer();
            CultureInfo culture = new CultureInfo("en-US");

            synthesizer.SelectVoiceByHints(System.Speech.Synthesis.VoiceGender.Female, System.Speech.Synthesis.VoiceAge.Teen, 1, culture);
            synthesizer.Speak(listBox1.SelectedItem.ToString());
        }
Пример #22
0
 protected override void Execute(CodeActivityContext context)
 {
     using (var synthesizer = new System.Speech.Synthesis.SpeechSynthesizer())
     {
         var text = Text.Get(context);
         synthesizer.Speak(text);
     }
 }
Пример #23
0
 static void Init()
 {
     if (_provider == null)
     {
         _provider = new Speech.Synthesis.SpeechSynthesizer();
         _provider.SetOutputToDefaultAudioDevice();
     }
 }
Пример #24
0
        public ActionResult Next(string Next, FormCollection fc)
        {
            System.Speech.Synthesis.SpeechSynthesizer s = new System.Speech.Synthesis.SpeechSynthesizer();
            s.Speak("Hello welcome to my website");


            return(Redirect("/Post_Job/Index"));
        }
Пример #25
0
 void _cmdStop_Click(object sender, EventArgs e)
 {
   if (ss != null)
   {
     ss.Pause();
     ss.Dispose();
     ss = null;
   }
 }
Пример #26
0
        static void SayString(string s)
        {
            System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer();

            synth.SetOutputToDefaultAudioDevice();
            synth.SelectVoiceByHints(System.Speech.Synthesis.VoiceGender.Female, System.Speech.Synthesis.VoiceAge.Senior);
            synth.Volume = 100;
            synth.Rate   = 0;
            synth.Speak(s);
        }
Пример #27
0
        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);
        }
Пример #28
0
 public void _Speak(string word)
 {
   if (ss == null)
   {
     ss = new System.Speech.Synthesis.SpeechSynthesizer();
     ss.Volume = _volume;
     ss.Rate = _rate;
   }
   ss.SpeakAsync(word);
 }
Пример #29
0
        private void PlayBackMessage(object sender, EventArgs e)
        {
            IDataObject dataObject = Clipboard.GetDataObject();

            if (dataObject.GetDataPresent(DataFormats.Text))
            {
                string str = (string)dataObject.GetData(DataFormats.Text);
                System.Speech.Synthesis.SpeechSynthesizer sp = new System.Speech.Synthesis.SpeechSynthesizer();
                sp.Speak(str);
            }
        }
Пример #30
0
 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);
 }
Пример #31
0
        private void SpeechCaptchaButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            System.Speech.Synthesis.SpeechSynthesizer oSpeechSynthesizer = new System.Speech.Synthesis.SpeechSynthesizer();

            oSpeechSynthesizer.Volume = 100;

            foreach (char objchar in CaptchaText.Text)
            {
                oSpeechSynthesizer.Speak(objchar.ToString());
            }
        }
Пример #32
0
        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();
        }
Пример #33
0
 public void Play()
 {
     using (var synth = new System.Speech.Synthesis.SpeechSynthesizer())
     {
         synth.SelectVoiceByHints((System.Speech.Synthesis.VoiceGender)VoiceGender, (System.Speech.Synthesis.VoiceAge)VoiceAge, VoicePosition, new CultureInfo(CultureInfo));
         synth.SetOutputToDefaultAudioDevice();
         synth.Volume = Volume;
         synth.Rate   = Rate;
         synth.Speak(Text);
     }
 }
Пример #34
0
        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;
        }
Пример #35
0
        public MainWin()
        {
            InitializeComponent();
            说话啦 = new System.Speech.Synthesis.SpeechSynthesizer();
            string[] ports = System.IO.Ports.SerialPort.GetPortNames();
            comboBoxCOMName.Items.AddRange(ports);

            GraphPane 经纬Pane = 经纬view.GraphPane;
            经纬Pane.Title.Text = "轨迹点(经、纬)实时显示";
            经纬Pane.XAxis.Title.Text = "经度";
            经纬Pane.YAxis.Title.Text = "纬度";
            LineItem 经纬Curve = 经纬Pane.AddCurve("轨迹", 经纬Pointlist, Color.Red, SymbolType.Diamond);
            经纬view.AxisChange();

            GraphPane XYPane = XYview.GraphPane;
            XYPane.Title.Text = "轨迹点(X、Y)实时显示";
            XYPane.XAxis.Title.Text = "X";
            XYPane.YAxis.Title.Text = "Y";
            LineItem XYCurve = XYPane.AddCurve("轨迹", 经纬Pointlist, Color.Blue, SymbolType.Diamond);
            XYview.AxisChange();
        }
Пример #36
0
        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 = "";
        }
Пример #37
0
		public List<string> getSystemVoices()
		{
			List<string> voices = new List<string> ();
			#if __WIN32__
			using(var speech = new SpeechEngine()) {
				var voicelist = speech.GetInstalledVoices();
				foreach(InstalledVoice v in voicelist) {
					if (v.Enabled)
					{
						Console.WriteLine(v.VoiceInfo.Name);
						voices.Add(v.VoiceInfo.Name);
					}
				}
			}
			#else
			NSApplication.SharedApplication.InvokeOnMainThread (() => {
				foreach (var voice in SpeechEngine.AvailableVoices) {
					voices.Add (voice);
				}
			});
			#endif
				
			return voices;
		}
Пример #38
0
 static void Main(string[] args)
 {
     var syn = new System.Speech.Synthesis.SpeechSynthesizer();
     syn.SelectVoice("Microsoft Server Speech Text to Speech Voice (ja-JP, Haruka)");
     syn.Speak("こんにちは");
 }
Пример #39
0
 void engine_SpeechRecognized(object sender, System.Speech.Recognition.SpeechRecognizedEventArgs e)
 {
     System.Speech.Synthesis.SpeechSynthesizer reader = new System.Speech.Synthesis.SpeechSynthesizer();
     System.Speech.Recognition.SpeechRecognitionEngine engine = new System.Speech.Recognition.SpeechRecognitionEngine();
     try
     {
         engine = new System.Speech.Recognition.SpeechRecognitionEngine();
         String message = "";
         String results = e.Result.Text;
         if (!listening)
         {
             return;
         }
         switch (results)
         {
             case "help":
                 reader.Speak("The available commands are restart, shutdown, status report, and players.");
                 Logger.Log(LogType.ConsoleOutput, "The available commands are restart, shutdown, status report, and a players.");
                 bVoice.ForeColor = System.Drawing.Color.Black;
                 results = "";
                 engine.RecognizeAsyncStop();
                 engine.Dispose();
                 listening = false;
                 break;
             case "restart":
                 reader.Speak("The server is now restarting.");
                 ShutdownParams param = new ShutdownParams(ShutdownReason.Restarting, TimeSpan.FromSeconds(5), true, true, "Restarting", Player.Console);
                 Server.Shutdown(param, true);
                 bVoice.ForeColor = System.Drawing.Color.Black;
                 results = "";
                 engine.RecognizeAsyncStop();
                 engine.Dispose();
                 listening = false;
                 break;
             case "shutdown":
                 reader.Speak("The server is now shutting down.");
                 Shutdown(ShutdownReason.ShuttingDown, true);
                 bVoice.ForeColor = System.Drawing.Color.Black;
                 results = "";
                 engine.RecognizeAsyncStop();
                 engine.Dispose();
                 listening = false;
                 break;
             case "status report":
                 reader.Speak("Server has been up for " + Math.Round(DateTime.UtcNow.Subtract(Server.StartTime).TotalHours, 1, MidpointRounding.AwayFromZero) + " hours.");
                 Player.Console.ParseMessage("/sinfo", true, false);
                 bVoice.ForeColor = System.Drawing.Color.Black;
                 results = "";
                 engine.RecognizeAsyncStop();
                 engine.Dispose();
                 listening = false;
                 break;
             case "players":
                 foreach (Player p in Server.Players)
                 {
                     message += p.Name;
                 }
                 reader.Speak(message);
                 Player.Console.ParseMessage("/players", true, false);
                 bVoice.ForeColor = System.Drawing.Color.Black;
                 results = "";
                 engine.RecognizeAsyncStop();
                 engine.Dispose();
                 listening = false;
                 break;
             default:
                 bVoice.ForeColor = System.Drawing.Color.Black;
                 results = "";
                 engine.RecognizeAsyncStop();
                 engine.Dispose();
                 listening = false;
                 break;
         }
     }
     catch(Exception)
     {
         //Audio Device is either missing or damaged, actual Exception is System.Speech.Internal.Synthesis.AudioException
         engine.RecognizeAsyncStop();
         engine.Dispose();
         return;
     }
 }
        private void ButtonVoiceSpecimenDescription_Click(object sender, RoutedEventArgs e)
        {
            using (System.Speech.Synthesis.SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer())
            {
                synth.SetOutputToDefaultAudioDevice();

                System.Speech.Synthesis.PromptBuilder builder = new System.Speech.Synthesis.PromptBuilder();
                builder.AppendTextWithHint("S12", System.Speech.Synthesis.SayAs.NumberCardinal);
                builder.AppendTextWithHint("10456", System.Speech.Synthesis.SayAs.SpellOut);

                synth.Speak(builder);
            }
        }
Пример #41
0
 public override void HandleTrigger(TriggerInput _Input)
 {
     var sam = new System.Speech.Synthesis.SpeechSynthesizer();
     sam.SpeakAsync(text);
 }