コード例 #1
0
ファイル: Program.cs プロジェクト: GAM-4-5/SpaceRTS
        static void Main()
        {
            Thread serverThread = new Thread(() => Coms.Initilize());

            serverThread.Start();

            using (var game = new Game())
                game.Run();

            serverThread.Abort();
        }
コード例 #2
0
        /*
         * Text to Speech
         */
        public Tts(Coms comModule)
        {
            this._comModule = comModule;
            Console.WriteLine("TTS constructor called");

            //create speech synthesizer
            tts = new SpeechSynthesizer();

            // show voices
            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {
                // Output information about all of the installed voices.
                Console.WriteLine("Installed voices -");
                foreach (InstalledVoice voice in synth.GetInstalledVoices())
                {
                    VoiceInfo info         = voice.VoiceInfo;
                    string    AudioFormats = "";
                    foreach (SpeechAudioFormatInfo fmt in info.SupportedAudioFormats)
                    {
                        AudioFormats += String.Format("{0}\n",
                                                      fmt.EncodingFormat.ToString());
                    }

                    Console.WriteLine(" Name:          " + info.Name);
                    Console.WriteLine(" Culture:       " + info.Culture);
                    Console.WriteLine(" Age:           " + info.Age);
                    Console.WriteLine(" Gender:        " + info.Gender);
                    Console.WriteLine(" Description:   " + info.Description);
                    Console.WriteLine(" ID:            " + info.Id);
                    Console.WriteLine(" Enabled:       " + voice.Enabled);
                    if (info.SupportedAudioFormats.Count != 0)
                    {
                        Console.WriteLine(" Audio formats: " + AudioFormats);
                    }
                    else
                    {
                        Console.WriteLine(" No supported audio formats found");
                    }

                    string AdditionalInfo = "";
                    foreach (string key in info.AdditionalInfo.Keys)
                    {
                        AdditionalInfo += String.Format("  {0}: {1}\n", key, info.AdditionalInfo[key]);
                    }

                    Console.WriteLine(" Additional Info - " + AdditionalInfo);
                    Console.WriteLine();
                }
            }
            //Console.WriteLine("Press any key to exit...");
            //Console.ReadKey();

            //set voice
            //tts.SelectVoiceByHints(VoiceGender.Male, VoiceAge.NotSet, 0, new System.Globalization.CultureInfo("pt-PT"));
            tts.SelectVoice("Microsoft Server Speech Text to Speech Voice (pt-PT, Nuno PTTS)");

            tts.SetOutputToDefaultAudioDevice();
            //set function to play audio after synthesis is complete
            tts.SpeakCompleted += new EventHandler <SpeakCompletedEventArgs>(tts_SpeakCompleted);
        }