Exemplo n.º 1
0
 public void speak(string word)
 {
     try
     {
         SpeechSynthesizer voice = new SpeechSynthesizer();
         switch (cmbbox.SelectedIndex)
         {
             case 0:
                 voice.SelectVoiceByHints(VoiceGender.NotSet);
                 break;
             case 1:
                 voice.SelectVoiceByHints(VoiceGender.Male);
                 break;
             case 2:
                 voice.SelectVoiceByHints(VoiceGender.Female);
                 break;
             case 3:
                 voice.SelectVoiceByHints(VoiceGender.Neutral);
                 break;
             default:
                 voice.SelectVoiceByHints(VoiceGender.NotSet);
                 break;
         }
         voice.SpeakAsync(word);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private SpeechSynthesizer BuildSynth(string gender)
        {
            var synth = new SpeechSynthesizer();
            if (!string.IsNullOrEmpty(gender) && gender.ToUpper() == "BOY")
            {
                synth.SelectVoiceByHints(VoiceGender.Male);
            }
            else
            {
                synth.SelectVoiceByHints(VoiceGender.Female);
            }

            return synth;
        }
Exemplo n.º 3
0
        float confidenceSum       = 0.0f;                //Accumulated Confidence Level

        //<Speech Initializer>
        public void InitializeSpeech(VoicePad_Window vpw)
        {
            //Assign VPW
            vPW = vpw;
            //Initialize a New Listener
            listener = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));
            //Initialize a new Speaker
            speaker = new SpeechSynthesizer();
            //Setup Voice / Language
            speaker.SelectVoiceByHints(VoiceGender.Male);
            speaker.Rate = 1;
            //Setup Listening Audio Device
            listener.SetInputToDefaultAudioDevice();
            //Setup Events
            listener.SpeechRecognized   += new EventHandler <SpeechRecognizedEventArgs>(Event_SpeechRecognized);
            listener.SpeechDetected     += new EventHandler <SpeechDetectedEventArgs>(Event_SpeechDetected);
            listener.SpeechHypothesized += new EventHandler <SpeechHypothesizedEventArgs>(Event_SpeechHypothesized);
            listener.AudioStateChanged  += new EventHandler <AudioStateChangedEventArgs>(Event_AudioStateChanged);
            //Learn Keywords/Grammer, Load to Listener
            keywords_complete.AddRange(keywords_std);
            keywords_complete.AddRange(keywords_hex);
            keywords_complete.AddRange(keywords_editor);
            Choices keyChoices     = new Choices(keywords_complete.ToArray());
            Grammar currentGrammar = new Grammar(new GrammarBuilder(keyChoices));

            listener.LoadGrammar(currentGrammar);
            //Start Listening to Speech
            listener.RecognizeAsync(RecognizeMode.Multiple);
            //Greet User
            speaker.SpeakAsync("Welcome to VoicePad, for AVR Assembly");
        }
Exemplo n.º 4
0
        public Form_Home(Employee employee)
        {
            InitializeComponent();

            newemployee = employee.CreateEmployee();

            pnl_Options.BackColor = Color.FromArgb(41, 44, 51);

            lbl_HeadLine.Top  = pnl_Background.Top - (pnl_Background.Top / 5);
            lbl_HeadLine.Left = (pnl_Background.Width / 5);
            lbl_HeadLine.Text = "Hello" + " " + newemployee.Fullname;

            if (IsManager(newemployee))
            {
                btn_CarExtra.Enabled = true;
                btn_Employee.Enabled = true;
                btn_Role.Enabled     = true;
            }
            else
            {
                btn_CarExtra.Enabled = false;
                btn_Employee.Enabled = false;
                btn_Role.Enabled     = false;
            }

            synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen);
            synthesizer.SpeakAsync("Hello" + " " + newemployee.Fullname);
            //     synthesizer.SpeakAsync("Welcome Yoni");
        }
        private void speech(string text)
        {
            SpeechSynthesizer _SS = new SpeechSynthesizer();

            _SS.SelectVoiceByHints(VoiceGender.Female);
            _SS.Speak(text);
        }
Exemplo n.º 6
0
        public Form1()
        {
            list.Add(new string[]
            {
                "hello", "how are you", "what time is it", "what is your name", "what is today", "open google",
                "sleep", "wake", "open office", "close office", "hay, edith", "minimize", "maximize",
                "tell me a joke"
            });

            Grammar gr = new Grammar(new GrammarBuilder(list));



            s.SelectVoiceByHints(VoiceGender.Female);
            s.Speak(greet_action());


            try
            {
                rec.RequestRecognizerUpdate();
                rec.LoadGrammarAsync(gr);
                rec.SetInputToDefaultAudioDevice();
                rec.RecognizeAsync(RecognizeMode.Multiple);
                rec.SpeechRecognized += rec_SpeechRecognized;
            }
            catch
            {
                return;
            }



            InitializeComponent();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new Speech Recognizer Object
        /// </summary>
        public Recognizer(Action end, Action <string, string, bool> result)
        {
            //Inform the ViewcontrollerConnector
            ViewControllerConnector.StartedCommandRecognition = true;

            _recognizer.LoadGrammar(new Grammar(new GrammarBuilder(new Choices(CommandHandler.GetCommands()))));

            _recognizer.SpeechRecognized          += speech_Recognized;
            _recognizer.SpeechDetected            += _recognizer_SpeechDetected;
            _recognizer.SpeechRecognitionRejected += _recognizer_SpeechRecognitionRejected;
            _recognizer.SpeechHypothesized        += _recognizer_SpeechHypothesized;

            _recognizer.SetInputToDefaultAudioDevice();
            _recognizer.RecognizeAsync(RecognizeMode.Single);

            synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
            synthesizer.Volume = 100;

            synthesizer.Rate = 0;

            _End = end;

            ResultCallback = result;

            timer.Interval = TimeSpan.FromSeconds(5);
            timer.Tick    += Timer_Tick;
            timer.Start();
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            ChatterBotFactory factory = new ChatterBotFactory();

            ChatterBot        bot1        = factory.Create(ChatterBotType.CLEVERBOT);
            ChatterBotSession bot1session = bot1.CreateSession();

            ChatterBot        bot2        = factory.Create(ChatterBotType.PANDORABOTS, "b0dafd24ee35a477");
            ChatterBotSession bot2session = bot2.CreateSession();

            var f = new SpeechSynthesizer();

            f.SelectVoiceByHints(VoiceGender.Female);

            var m = new SpeechSynthesizer();

            m.SelectVoiceByHints(VoiceGender.Male);

            string s = "Hi";

            while (true)
            {
                Console.WriteLine("bot1> " + s);
                m.Speak(s);

                s = bot2session.Think(s);
                Console.WriteLine("bot2> " + s);
                f.Speak(s);

                s = bot1session.Think(s);
            }
        }
Exemplo n.º 9
0
        public MainWindow()
        {
            InitializeComponent();
            speechRecognizer.SpeechRecognized += speechRecognizer_SpeechRecognized;
            synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Child);
            synth.SetOutputToDefaultAudioDevice();
            synth.Speak("Whats up and welcome to project Bonzer, my name is Darrell and I will be helping you today.");

            DBInfoRetrieval tableInfo = new DBInfoRetrieval();

            tableInfo.PrintTableNames();
            tableInfo.PrintColumnsAndTables();

            // LinguisticAnalyzer myAnalyzer = new LinguisticAnalyzer();
            //myAnalyzer.DemoParse();

            GrammarBuilder grammarBuilder = new GrammarBuilder();
            Choices        commandChoices = new Choices("show all", "list the", "list all", "find me", "print the");

            grammarBuilder.Append(commandChoices);

            Choices valueChoices = new Choices();

            AddChoices(valueChoices, tableInfo.ReturnTableNames());
            //valueChoices.Add("actors", "films", "stores");
            valueChoices.Add("and", "there", "their", "with");
            grammarBuilder.Append(valueChoices);

            speechRecognizer.LoadGrammar(new Grammar(grammarBuilder));
            speechRecognizer.SetInputToDefaultAudioDevice();
        }
Exemplo n.º 10
0
 private SpeechOutput()
 {
     _synth = new SpeechSynthesizer();  
     _synth.SelectVoiceByHints(VoiceGender.Female);
     _synth.Rate = 1;
     _synth.Volume = 90; 
 }
Exemplo n.º 11
0
        ///<summary>Throws an exception of unable to find a suitable microphone.</summary>
        public VoiceController(VoiceCommandArea area, bool doIncludeGlobal = true, bool isGivingFeedback = true)
        {
            _isGivingFeedback = isGivingFeedback;
            List <VoiceCommandArea> listAreas = new List <VoiceCommandArea> {
                area
            };

            if (doIncludeGlobal)
            {
                listAreas.Add(VoiceCommandArea.Global);
            }
            _listCommands = VoiceCommandList.GetCommands(listAreas);
            Choices commandChoices = new Choices();

            commandChoices.Add(_listCommands.SelectMany(x => x.Commands).ToArray());
            // Create a GrammarBuilder object and append the Choices object.
            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(commandChoices);
            // Create the Grammar instance and load it into the speech recognition engine.
            Grammar g = new Grammar(gb);

            _recEngine = new SpeechRecognitionEngine();
            _recEngine.LoadGrammarAsync(g);
            _recEngine.SetInputToDefaultAudioDevice();
            _recEngine.RecognizeAsync(RecognizeMode.Multiple);            //Recognize speech until we tell it to stop
            _recEngine.SpeechRecognized += RecEngine_SpeechRecognized;
            _synth.SetOutputToDefaultAudioDevice();
            _synth.SelectVoiceByHints(VoiceGender.Female);
            IsListening = true;
        }
Exemplo n.º 12
0
        public Attendance()
        {
            SpeechRecognitionEngine rec = new SpeechRecognitionEngine();

            //list.Add(new string[] {"one","two","three","four","five","six","seven","eight","nine","ten" });
            list.Add(File.ReadAllLines(@"C:\Users\Shehroz\Desktop\OOP\oopfinal\AttendanceId.txt"));
            //string[] english =File.ReadAllLines(@"C:\Users\Shehroz\Desktop\OOP\oopfinal\AttendanceId.txt");



            Grammar gr = new Grammar(new GrammarBuilder(list));

            try
            {
                rec.RequestRecognizerUpdate();
                rec.LoadGrammar(gr);
                rec.SpeechRecognized += rec_SpeechRecognized;
                //rec.SpeechRecognized += Attendance_Loadl;
                rec.SetInputToDefaultAudioDevice();
                rec.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch { return; }

            s.SelectVoiceByHints(VoiceGender.Female);
            s.Speak("Assalamalikum ");
            s.Speak("my name is amy");
            s.Speak("if you want to mark your attendance first say hey amy");



            InitializeComponent();
        }
Exemplo n.º 13
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //GUI time und date
            lbl_time.Text = DateTime.Now.ToShortTimeString();
            lbl_date.Text = DateTime.Now.ToLongDateString();

            tab_control.SelectTab(tab_text);

            //commands
            Choices commands = new Choices();
            string  path     = Directory.GetCurrentDirectory() + "\\commands.txt";

            commands.Add(File.ReadAllLines(path));

            //grammar
            GrammarBuilder gbuilder = new GrammarBuilder();

            gbuilder.Append(commands);

            //grammar (nicht genutzt in dieser version)
            Grammar          grammar  = new Grammar(gbuilder);
            DictationGrammar dgrammar = new DictationGrammar();

            //laden aller Engines
            h.LoadGrammarAsync(grammar);

            h.SetInputToDefaultAudioDevice();
            h.SpeechRecognized += recEngine_SpeechRecognized;

            h.RecognizeAsync(RecognizeMode.Multiple);
            s.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);

            s.SpeakAsync("Wie kann ich dir helfen");
        }
Exemplo n.º 14
0
        static void EventCounts(object sender, FbRemoteEventEventArgs args)
        {
            string       ConnectionString     = "User ID=" + userdb + ";Password="******";Database=c:/trilogis/trilogis.fb20; " + "DataSource=localhost;Charset=NONE;";
            FbConnection addDetailsConnection = new FbConnection(ConnectionString);

            addDetailsConnection.Open();
            SpeechSynthesizer synthesizer = new SpeechSynthesizer();

            synthesizer.SetOutputToDefaultAudioDevice();
            synthesizer.SelectVoiceByHints(VoiceGender.Female);
            synthesizer.Volume = 100;
            synthesizer.Rate   = 0;
            using (FbCommand cmd = new FbCommand("SELECT CLIENTEID FROM ULTIMOPRONTO WHERE ID = (SELECT MAX(ID) FROM ULTIMOPRONTO)", addDetailsConnection))
            {
                string clienti = cmd.ExecuteScalar().ToString();

                if (clienti == "")
                {
                    FbCommand scontrino = new FbCommand("SELECT LOTTONUMERO FROM LOTTI WHERE LOTTOID =(SELECT LOTTOID FROM ULTIMOPRONTO WHERE ID = (SELECT MAX(ID) FROM ULTIMOPRONTO))", addDetailsConnection);
                    int       n         = Convert.ToInt32(scontrino.ExecuteScalar());
                    //MessageBox.Show(n.ToString());
                    synthesizer.Speak("Scontrino " + n.ToString());
                }
                else
                {
                    FbCommand nomecliente = new FbCommand("SELECT CLIENTERAGIONESOCIALEUP FROM CLIENTI WHERE CLIENTEID =(SELECT CLIENTEID FROM ULTIMOPRONTO WHERE ID = (SELECT MAX(ID) FROM ULTIMOPRONTO))", addDetailsConnection);
                    string    clientenome = nomecliente.ExecuteScalar().ToString();
                    //MessageBox.Show(clientenome);
                    synthesizer.Speak(clientenome);
                }
            }
        }
Exemplo n.º 15
0
        public MainWindow()
        {
            foreach (var type in typeof(HostConfig).Assembly.GetExportedTypes().Where(t => t.Namespace == typeof(HostConfig).Namespace))
            {
                TypeDescriptor.AddAttributes(type, new ExpandableObjectAttribute());
            }

            InitializeComponent();

            _synth = new SpeechSynthesizer();
            _synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
            _synth.SetOutputToDefaultAudioDevice();
            _timer          = new DispatcherTimer();
            _timer.Interval = TimeSpan.FromSeconds(1);
            _timer.Tick    += _timer_Tick;
            _timer.Start();

            var hostConfig = new HostConfig();

            hostConfig.AdaptiveCard.BackgroundColor = Colors.WhiteSmoke.ToString();
            this.Renderer = new XamlRendererExtended(hostConfig, this.Resources, _onAction, _OnMissingInput);
            this.hostConfigEditor.SelectedObject = hostConfig;

            foreach (var style in Directory.GetFiles(@"..\..\..\..\..\..\samples\v1.0\HostConfig", "*.json"))
            {
                this.hostConfigs.Items.Add(new ComboBoxItem()
                {
                    Content = Path.GetFileNameWithoutExtension(style),
                    Tag     = style
                });
            }
        }
        public void speech(string vocalmessage)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.Speak(vocalmessage);
            synth.SelectVoiceByHints(VoiceGender.Female);
        }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            var client = new OpenWeatherAPI.OpenWeatherAPI("6ac232d2dac00bdaa191f6d3db9cbeec");

            SpeechSynthesizer synthesizer = new SpeechSynthesizer();

            synthesizer.SelectVoiceByHints(VoiceGender.Female);
            Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "C:\\Users\\Mi'Angel\\Downloads\\Genesis-1ac8c357b5fb.json");

            synthesizer.Speak("Hello. I'm Genesis.");
            StreamingMicRecognizeAsync(2).Wait();
            Console.WriteLine(speechResult);

            if (speechResult.Contains("weather"))
            {
                // Get location

                var city = "Phoenix, Arizona";
                //Get API result
                //To get tomorrow or yesterdays weather or a forecast, we can use a switch statement to return a result
                //as a subContains if speech aslo contains today, tomorrow



                synthesizer.Speak($"Fetching weather data for '{city}'");
                var results = client.Query(city);

                synthesizer.Speak($"The temperature in {city} is {results.Main.Temperature.FahrenheitCurrent} degrees. There is {results.Wind.SpeedFeetPerSecond.ToString("0")} feet per second wind in the {results.Wind.Direction} direction.");
            }
        }
Exemplo n.º 18
0
        public Genesis()
        {
            SpeechRecognitionEngine rec = new SpeechRecognitionEngine();

            //Necessary commands

            list.Add(new String[] { "hello", "how are you", "who are you", "what time is it",
                                    "what day is it", "open bing", "open google", "open youtube", "open this pc", "open computer", "open my computer",
                                    "open document", "open my document", "open documents", "open my documents",
                                    "open download", "open my download", "open downloads", "open my downloads",
                                    "open notepad", "open note pad", "open word", "open command prompt", "open google chrome", "open chrome", "open firefox",
                                    "open mozilla firefox", "open excel", "open cmd", "quit", "exit", "show help", "show all commands", "show commands",
                                    "hide commands", "hide all commands", "hide help" });

            Grammar gr = new Grammar(new GrammarBuilder(list));

            try
            {
                rec.RequestRecognizerUpdate();
                rec.LoadGrammar(gr);
                rec.SpeechRecognized += rec_SpeechRecognized;
                rec.SetInputToDefaultAudioDevice();
                rec.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch
            {
                return;
            }
            s.SelectVoiceByHints(VoiceGender.Female);
            s.Speak("Starting Genesis");
            InitializeComponent();
        }
Exemplo n.º 19
0
        private static void Main(string[] args)
        {
            var specials = new int[] { 4, 7 };

            Debug.Assert(!specials.Contains(1));

            for (int i = 1; i < 100; i++)
            {
                var buzzes = CheckLiteralSpecials(specials, i);

                foreach (var s in specials)
                {
                    buzzes += NumBuzzesFromMultiples(s, i);
                }

                SpeechSynthesizer synthesizer = new SpeechSynthesizer();
                synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Child);
                synthesizer.Volume = 100;
                synthesizer.Rate   = 7;

                if (buzzes > 0)
                {
                    Console.WriteLine(CreateBuzzString(buzzes));
                    synthesizer.Speak(CreateBuzzString(buzzes));
                }
                else
                {
                    Console.WriteLine(i.ToString());
                    synthesizer.Speak(i.ToString());
                }
            }
        }
Exemplo n.º 20
0
 public VoiceModel()
 {
     _synthesizer = new SpeechSynthesizer();
     _synthesizer.SetOutputToDefaultAudioDevice();
     _synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
     _synthesizer.Volume = 80;
 }
Exemplo n.º 21
0
        private void afterMinute_Tick(object sender, EventArgs e)
        {
            DateTime alarmTime = DateTime.Parse(lblAlarmTime.Text);
            DateTime nowTIme   = DateTime.Parse(currentTime.Text);

            TimeSpan difference = nowTIme - alarmTime;

            if (difference.Minutes == 01 && minute == false)
            {
                string AccountSid = "ACde508c15e365dd92a9ad401840e03733";
                string AuthToken  = "9a6804457c7d00fd1c1bd15b01c4b193";

                TwilioClient.Init(AccountSid, AuthToken);

                var message = MessageResource.Create(
                    body: "This message was sent because I was unable to wake up from my alarm. Yes I am a failure I know. Please call to wake me up.",
                    from: new Twilio.Types.PhoneNumber("+14402765334"),
                    to: new Twilio.Types.PhoneNumber("+12167744556")
                    );

                minute = true;
                audio.Stop();
            } //end if

            if (difference.Minutes >= 02 && minute == true)
            {
                synthesizer.Volume = 100; // 0...100
                synthesizer.Rate   = 5;   // -10...10
                synthesizer.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult);


                synthesizer.SpeakAsync("AAAAAAAAAAAAAAAAAAA WAKE UP AAAAAAAAAAAAAAAAAAAAAAAAAAA WAKE UP AAAAAAAAAAAHHHHHHH");
            }
        }
Exemplo n.º 22
0
        public FrmPrincipal()
        {
            SpeechRecognitionEngine rec = new SpeechRecognitionEngine();

            // Ajout de commandes tels qu'Ouvrir Google Chrome (voir le fichier txt)
            list.Add(File.ReadAllLines(@"C:\Users\Proprietaire\Documents\Projet_Perso\PROJET\BCA_MakingAnIA\BCA_MakingAnIA\Commands\Commands.txt"));



            // Ajout d'une nouvelle grammaire
            Grammar gr = new Grammar(new GrammarBuilder(list));

            s.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult);
            s.Speak("Attendez quelques secondes, ça arrive");

            try
            {
                rec.RequestRecognizerUpdate();
                rec.LoadGrammar(gr);
                rec.SpeechRecognized += rec_SpeachRecognized;
                rec.SetInputToDefaultAudioDevice();
                rec.RecognizeAsync(RecognizeMode.Multiple);
            } catch (Exception)
            {
                MessageBox.Show("Erreur", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }



            InitializeComponent();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // From example code on MS-website

            // Grammar
            Choices sr_choices = new Choices();

            sr_choices.Add(new string[] { "schalte die lichter ein", "öffne word", "öffne excel", "öffne powerpoint", "öffne outlook" });
            GrammarBuilder sr_grb = new GrammarBuilder();

            sr_grb.Append(sr_choices);
            Grammar sr_gr = new Grammar(sr_grb);

            // Create and load a dictation grammar.
            sr_engine.LoadGrammar(sr_gr);

            // Add a handler for the speech recognized event.
            sr_engine.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(sr_engine_speech_recognized);
            sr_engine.SpeechDetected   += new EventHandler <SpeechDetectedEventArgs>(sr_engine_speech_detected);

            // Configure input to the speech recognizer.
            sr_engine.SetInputToDefaultAudioDevice();

            // Start asynchronous, continuous speech recognition.
            sr_engine.RecognizeAsync(RecognizeMode.Multiple);

            gui_output_box.Text += "Started speech recognition.\n";

            speech_synth.Rate = -10;

            speech_synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.NotSet);
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            Cleverbot cleverbot = new Cleverbot("API_KEY");

            Console.WriteLine("Speak Now");
            SpeechSynthesizer synthesizer = new SpeechSynthesizer();

            synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen); // to change VoiceGender and VoiceAge check out those links below
            synthesizer.Volume = 100;                                          // (0 - 100)
            synthesizer.Rate   = 0;                                            // (-10 - 10)
            while (true)
            {
                SpeechRecognitionEngine recognizer = new SpeechRecognitionEngine();
                Grammar dictationGrammar           = new DictationGrammar();
                recognizer.LoadGrammar(dictationGrammar);
                recognizer.SetInputToDefaultAudioDevice();
                RecognitionResult result = recognizer.Recognize();
                string            res    = "";
                if (result == null)
                {
                    res = "did you get that?";
                }
                else
                {
                    res = result.Text;
                }
                Console.WriteLine(res);
                string question = cleverbot.Ask(res);
                Console.WriteLine("Cleverbot: " + question);
                synthesizer.SpeakAsync(question);
            }
        }
Exemplo n.º 25
0
        public Form1()
        {
            SpeechRecognitionEngine rec = new SpeechRecognitionEngine();

            /// ALWAAYS ADD NEW COMMANDS HERE THIS IS A LIST OF VIABLE COMMANDS KEEP LOWER CASE

            list.Add(new String[] { "hello", "how are you", "What time is it", "What day is it", "I need to search the web", "open google", "wake up", "sleep", "caip", "go to sleep" });

            Grammar gr = new Grammar(new GrammarBuilder(list));

            try
            {
                rec.RequestRecognizerUpdate();
                rec.LoadGrammar(gr);
                rec.SpeechRecognized += rec_SpeachRecognized;
                rec.SetInputToDefaultAudioDevice();
                rec.RecognizeAsync(RecognizeMode.Multiple);
            }catch { return; }



            s.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen, 1);

            InitializeComponent();
        }
Exemplo n.º 26
0
        private void readWord()
        {
            if (lblWord.Text != null && (lblWord.Text.ToUpper() != "WORD"))
            {
                if (textReader != null)
                {
                    textReader.Dispose();
                }

                textReader = new SpeechSynthesizer();
                textReader.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Senior);
                textReader.Volume = 100;
                textReader.Rate   = -6;

                StringBuilder word = new StringBuilder();

                char[] wordAsArray = lblWord.Text.ToCharArray();
                for (int i = 0; i < wordAsArray.Length - 1; i++)
                {
                    word.Append(wordAsArray[i]);
                    word.Append(" ");
                }
                word.Append(wordAsArray[wordAsArray.Length - 1]);

                textReader.SpeakAsync(word.ToString() + "\t\t\t" + lblWord.Text);
            }
        }
Exemplo n.º 27
0
        private void SpeakButton_Click(object sender, EventArgs e)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.Rate   = SpeedTrackBar.Value;
            synth.Volume = SoundTrackBar.Value;
            if (PersonComboBox.Text == "Male")
            {
                synth.SelectVoiceByHints(VoiceGender.Male);
            }
            if (PersonComboBox.Text == "Female")
            {
                synth.SelectVoiceByHints(VoiceGender.Female);
            }
            synth.Speak(SpeechTextBox.Text);
        }
Exemplo n.º 28
0
 private void Narrador(object texto)
 {
     voz.SelectVoiceByHints(VoiceGender.Female);
     voz.Rate = Velocidad.Value;
     voz.SetOutputToDefaultAudioDevice();
     voz.Speak(texto.ToString());
 }
Exemplo n.º 29
0
        public Form2()
        {
            s.SelectVoiceByHints(VoiceGender.Female);

            InitializeComponent();
            WebBrowser web = tabControl.SelectedTab.Controls[0] as WebBrowser;

            NavigateToAddress(homePage);
            s.Speak("Hi, my name is Gabriel Chrome");
            textBox1.Text        = homePage;
            this.WindowState     = FormWindowState.Normal;
            this.FormBorderStyle = FormBorderStyle.Fixed3D;
            this.MaximizeBox     = true;
            this.MinimizeBox     = true;
            this.StartPosition   = FormStartPosition.CenterScreen;
            // Remove the control box so the form will only display client area.
            this.ControlBox   = true;
            this.AcceptButton = button1;
            button5.BackColor = Color.LightGreen;
            button5.ForeColor = Color.Green;
            button5.FlatStyle = FlatStyle.Flat;
            button8.BackColor = Color.LightBlue;
            button8.ForeColor = Color.Blue;
            button8.FlatStyle = FlatStyle.Flat;
            button6.BackColor = Color.Red;
            button6.ForeColor = Color.LightSteelBlue;
            button6.FlatStyle = FlatStyle.Flat;
        }
Exemplo n.º 30
0
        public InjectInterface()
        {
            InjectInterfaceInitialized(this, EventArgs.Empty);
            _watchDog = new Timer(1500);

            _synth = new SpeechSynthesizer {
                Volume = 100
            };
            _synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult, 0, new CultureInfo("en-us"));

            InjectorOnline += pid => _synth.SpeakAsync("Injector Online!");

            _watchDog.Elapsed += (sender, args) =>
            {
                if (_flag)
                {
                    _flag = false;
                }
                else
                {
                    _watchDog.Stop();
                    if (InjectorOffline != null)
                    {
                        InjectorOffline("Unknow Error");
                    }
                    _synth.SpeakAsync(Process.GetProcessesByName("osu!").Any() ? "Injector Offline!" : "See you!");
                }
            };
        }
Exemplo n.º 31
0
        public Form1()
        {
            SpeechRecognitionEngine rec = new SpeechRecognitionEngine();

            list.Add(new String[] { "Cortin", "hello", "how are you", "what time is it", "what day is it", "open google", "open youtube"
                                    , "wake", "sleep", "Cortin wake up", "restart", "update", "open universe sandbox 2", "close universe sandbox 2",
                                    "whats the weather like", "cortin" });


            Grammar gram = new Grammar(new GrammarBuilder(list));

            try
            {
                rec.RequestRecognizerUpdate();
                rec.LoadGrammar(gram);
                rec.SpeechRecognized += rec_SpeechRecognized;
                rec.SetInputToDefaultAudioDevice();
                rec.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch { return; }


            InitializeComponent();
            s.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
            s.Speak("Welcome");
        }
Exemplo n.º 32
0
        public ChatBot()
        {
            SpeechRecognitionEngine r = new SpeechRecognitionEngine();

            //Commands Recognization.
            list.Add(File.ReadAllLines(@"F:\ChatBotCommands\Commands.txt"));

            // Grammer Class
            Grammar gr = new Grammar(new GrammarBuilder(list));

            // Serial Port Class
            // SerialPort SP = new SerialPort("COM4",9600,Parity.None,8,StopBits.One);
            //try Block

            try
            {
                // Speech Recognization
                r.RequestRecognizerUpdate();
                r.LoadGrammar(gr);
                r.SpeechRecognized += r_SpeechRecognized;
                r.SetInputToDefaultAudioDevice();
                r.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch
            {
                return;
            }

            s.SelectVoiceByHints(VoiceGender.Male);
            s.Speak("Hello,My Name Is Vin..........Enter Your Name And Age");
            InitializeComponent();
        }
Exemplo n.º 33
0
        private static void Speak(string textToSpeak)
        {
            var syn = new SpeechSynthesizer();

            syn.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
            syn.Speak(textToSpeak);
        }
Exemplo n.º 34
0
 public void Speech(String source)
 {
     SpeechSynthesizer speaker = new SpeechSynthesizer();
     speaker.SelectVoiceByHints(VoiceGender.Female);
     speaker.Volume = 100;
     speaker.Rate = 0;
     speaker.Speak(source);
 }
Exemplo n.º 35
0
 private void Speakthread(object text)
 {
     SpeechSynthesizer speaker = new SpeechSynthesizer();
     speaker.Rate = -3;
     speaker.Volume = 100;
     speaker.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Child);
     speaker.Speak((string)text);
 }
Exemplo n.º 36
0
        // read text
        private static void Voice(string toSpeak)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.SelectVoiceByHints(VoiceGender.Female);
            synth.Rate = 1;
            synth.Speak(toSpeak);
        }
Exemplo n.º 37
0
 public Form1()
 {
     InitializeComponent();
     speaker = new SpeechSynthesizer();
     speaker.Rate = 1;
     speaker.Volume = 100;
     speaker.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
     initialize();
 }
Exemplo n.º 38
0
        /*
         * Text to Speech
         */
        public Tts()
        {
            //create speech synthesizer
            tts = new SpeechSynthesizer();
            tts.SetOutputToDefaultAudioDevice();

            //set voice
            tts.SelectVoiceByHints(VoiceGender.NotSet, VoiceAge.NotSet, 0, new System.Globalization.CultureInfo("pt-PT"));
        }
Exemplo n.º 39
0
        public Text2Speech()
        {
            synthesizer = new SpeechSynthesizer();

            synthesizer.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Child);

            synthesizer.Rate = 0;

            AllVoices = new List<VoiceInfo>();
        }
 static void Main(string[] args)
 {
     Console.WriteLine("Enter text to speak:");
     string TextToSpeak = Console.ReadLine(); 
     SpeechSynthesizer ss = new SpeechSynthesizer();
     ss.Volume = 100; //1 to 100
     ss.Rate = -3; // -10 to +10 
     ss.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Child);
     ss.SpeakAsync(TextToSpeak); 
     Console.Read();
 }
Exemplo n.º 41
0
 public void Play()
 {
     using (SpeechSynthesizer synth = new SpeechSynthesizer())
     {
         synth.SelectVoiceByHints(VoiceGender, VoiceAge, VoicePosition, new CultureInfo(CultureInfo));
         synth.SetOutputToDefaultAudioDevice();
         synth.Volume = Volume;
         synth.Rate = Rate;
         synth.Speak(Text);
     }
 }
Exemplo n.º 42
0
    public Server()
    {
        Form = new CustomPerPixelAlphaForm();
        FormSetProperties();
        FormDock();
        Form.Show();

        var clientBuildDirectory = Environment.CurrentDirectory + "\\..\\..\\..\\..\\..\\Reflecta.Client\\bin";
        var clientStartInfo = new ProcessStartInfo
        {
            FileName = clientBuildDirectory + "\\Client.exe",
            WorkingDirectory = clientBuildDirectory,
            WindowStyle = ProcessWindowStyle.Minimized
        };
        Client = Process.Start(clientStartInfo);

        OpenPipes();

        SpeechSynthesizer = new SpeechSynthesizer();
        SpeechSynthesizer.SelectVoiceByHints(VoiceGender.Female);
        SpeechSynthesizer.SpeakStarted += SpeechSynthesizer_SpeakStarted;
        SpeechSynthesizer.VisemeReached += SpeechSynthesizer_VisemeReached;
        SpeechSynthesizer.SpeakCompleted += SpeechSynthesizer_SpeakCompleted;

        SpeechRecognitionEngine = new SpeechRecognitionEngine();
        SpeechRecognitionEngine.UnloadAllGrammars();
        SpeechRecognitionEngine.LoadGrammar(new Grammar(new GrammarBuilder(KnownCommands)));
        SpeechRecognitionEngine.SpeechRecognized += SpeechRecognitionEngine_SpeechRecognized;
        SpeechRecognitionEngine.SetInputToDefaultAudioDevice();
        SpeechRecognitionEngine.RecognizeAsync(RecognizeMode.Multiple);

        KinectSensor = KinectSensor.GetDefault();
        KinectSensor.Open();

        BodyFrameSource = KinectSensor.BodyFrameSource;
        BodyFrameReader = BodyFrameSource.OpenReader();
        BodyFrameReader.FrameArrived += BodyFrameReader_FrameArrived;
        Bodies = null;
        BodyDESP = new DESPQuaternion[(int) MoCapKinectBone.Count];
        for (var i = 0; i < (int) MoCapKinectBone.Count; i++)
            BodyDESP[i] = new DESPQuaternion();

        HighDefinitionFaceFrameSource = new HighDefinitionFaceFrameSource(KinectSensor);
        HighDefinitionFaceFrameSource.TrackingQuality = FaceAlignmentQuality.High;
        HighDefinitionFaceFrameReader = HighDefinitionFaceFrameSource.OpenReader();
        HighDefinitionFaceFrameReader.FrameArrived += HighDefinitionFaceFrameReader_FrameArrived;
        FaceAlignment = new FaceAlignment();

        FaceDESP = new DESPQuaternion();
        FaceExpressionDESP = new DESPFloat[(int) MoCapKinectFacialExpression.Count];
        for (var i = 0; i < (int) MoCapKinectFacialExpression.Count; i++)
            FaceExpressionDESP[i] = new DESPFloat();
    }
Exemplo n.º 43
0
        //static constructor of the Class, which initialises the SpeechSynthesizer , and registers the several events
        static Speaker()
        {
            mainSynthesizer=new SpeechSynthesizer();
            mainSynthesizer.SelectVoiceByHints(DataStore.CurrentUser.SynthesizerVoiceGender);
            mainSynthesizer.SetOutputToDefaultAudioDevice();

            DataStore.VoiceGenderChanged += DataStore_VoiceGenderChanged;                       //DataStore's VoiceGenderChanged event which occurs when the gender of the TTS engine has changed
            MainWindow.VolumeChanged += MainWindow_VolumeChanged;                               //MainWindow VolumeChanged event which occurs when Volume of the TTS engine changes
            MainWindow.RateChanged += MainWindow_RateChanged;                                   //MainWindow RateChanged event which occurs when Synthesis Rate of the TTS engine changes
            //mainSynthesizer.SpeakStarted += MainSynthesizer_SpeakStarted;
            //mainSynthesizer.SpeakCompleted += MainSynthesizer_SpeakCompleted;
        }
Exemplo n.º 44
0
        public static void VocalSynthesis(string text, string culture, string filename, string voice)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();

            synth.SelectVoiceByHints(VoiceGender.Neutral, VoiceAge.NotSet, 1, new CultureInfo(culture));

            if (!string.IsNullOrEmpty(filename))
                synth.SetOutputToWaveFile(filename);
            if (!string.IsNullOrEmpty(voice))
                synth.SelectVoice(voice);

            synth.Speak(text);
        }
Exemplo n.º 45
0
        public static void Speak(string message)
        {
            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {
                synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);

                // Configure the audio output. 
                synth.SetOutputToDefaultAudioDevice();

                // Speak a string synchronously.
                synth.Speak(message);
            }
        }
Exemplo n.º 46
0
 /// <summary>
 /// 语音报警
 /// <summary>
 public void Alarm(string strAlarm)
 {
     try
     {
         SpeechSynthesizer Talker = new SpeechSynthesizer();
         Talker.Rate = 2;//控制语速(-10--10)
         Talker.Volume = 100;//控制音量
         Talker.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Child, 2, System.Globalization.CultureInfo.CurrentCulture);
         Talker.SpeakAsync(strAlarm);
     }
     catch (Exception ex)
     {
         Log.WriteLog("语音提示控件" + ex.ToString());
     }
 }
Exemplo n.º 47
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="AlfredSpeechProvider" /> class.
        /// </summary>
        /// <param name="console">The console.</param>
        public AlfredSpeechProvider([CanBeNull] IConsole console)
        {
            _speech = new SpeechSynthesizer();

            // Let's get verbose with the console
            if (console != null)
            {
                console.Log(LogHeader,
                            Resources.InitializingSpeechModule.NonNull(),
                            LogLevel.Verbose);

                // Enumerate all detected voices for diagnostic purposes. This takes ~60ms.
                LogInstalledVoices(console);
            }

            // We want Alfred to sound like an English butler so request the closest thing we can find
            var greatBritainCulture = new CultureInfo("en-GB");
            _speech.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Senior, 0, greatBritainCulture);

            // Set to slightly faster than normal
            _speech.Rate = 2;

            // Everything else is just logging, so... get out of here
            if (console == null)
            {
                return;
            }

            // Log what voice we're using
            var voice = _speech.Voice;
            if (voice != null)
            {
                var message = string.Format(CultureInfo.CurrentCulture,
                                            Resources.UsingVoiceLog.NonNull(),
                                            voice.Name);
                console.Log(LogHeader,
                            message.NonNull(),
                            LogLevel.Verbose);
            }
            else
            {
                console.Log(LogHeader,
                            Resources.UsingUnknownVoice.NonNull(),
                            LogLevel.Warning);
            }
        }
        public override void Say(String textToSay)
        {
            if (String.IsNullOrWhiteSpace(textToSay))
                throw new ArgumentException("Argument \"" + nameof(textToSay) + "\" cannot be null or empty.", nameof(textToSay));

            if (Enabled)
            {
                Task.Run(() =>
                {
                    using (SpeechSynthesizer speech = new SpeechSynthesizer())
                    {
                        speech.SelectVoiceByHints(VoiceGender.Female);

                        speech.Speak(new Prompt(textToSay));
                    }
                });
            }
        }
Exemplo n.º 49
0
        static void MedicationTaken(object val)
        {
            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {
                // Remove the below for UK/US version of speech – or replace da-DK
                synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);

                // Configure the audio output.
                synth.SetOutputToDefaultAudioDevice();

                // Speak a string synchronously.
                //synth.Speak("Good morning. Please remember to take your medication.");
                string s = "Medicin said time" + i + "times";
                synth.Speak(s);
                i++;
            }
        }
Exemplo n.º 50
0
 public static void startReading()
 {
     Reading = true;
     if(TalkMessages!= null)
     {
         SpeechSynthesizer synth = new SpeechSynthesizer();
         synth.SetOutputToDefaultAudioDevice();
         //synth.SetOutputToAudioStream()
         synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Adult, 22,
             new System.Globalization.CultureInfo("nl-BE"));
         while (TalkMessages.Count > 0)
         {
             string text = TalkMessages.Dequeue();
             synth.Speak(text);
             Thread.Sleep(2000);
         }
     }
     Reading = false;
 }
Exemplo n.º 51
0
        public static void ReadOutLoud(List<NewsSummary> ListOfSummaries)
        {
            using (SpeechSynthesizer synth = new SpeechSynthesizer())
            {
                synth.SetOutputToDefaultAudioDevice();
                synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
                // Speak a string synchronously.
                foreach (NewsSummary _summary in ListOfSummaries)
                {
                    string textToRead = _summary.title + ".\n" + _summary.source + " reports, " + _summary.digest + "\n\n";
                    try
                    {
                        synth.Speak(textToRead);
                    }
                    catch
                    {

                    }
                    Console.Write(textToRead); //*
                }
            }
        }
Exemplo n.º 52
0
        static void Main(string[] args)
        {
            //Initialize a new instance of the SpeechSynthesizer.
            SpeechSynthesizer synth = new SpeechSynthesizer();

            //Select a voice.
            synth.SelectVoiceByHints(VoiceGender.Female);

            synth.Rate = -2;

            //Configure the audio output.
            synth.SetOutputToDefaultAudioDevice();

            //Speak text string synchronously.
            string articleText = WebInteractions.Wiktionary.ReadArticle("test");
            if (articleText != null)
            {
                synth.Speak(articleText);
            }
            else
            {
                synth.Speak("I could not locate any information on that topic.");
            }
        }
Exemplo n.º 53
0
 private void save_Click(object sender, EventArgs e)
 {
     SpeechSynthesizer ss = new SpeechSynthesizer();
     if (male.Checked == true)
     {
         ss.SelectVoiceByHints(VoiceGender.Male);
     }
     else
     {
         ss.SelectVoiceByHints(VoiceGender.Female);
     }
     ss.Rate = rateBar.Value;
     ss.Volume = rateBar.Value;
     SaveFileDialog sfd = new SaveFileDialog();
     sfd.Filter = "Wave Files| *.wav";
     sfd.ShowDialog();
     ss.SetOutputToWaveFile(sfd.FileName);
     ss.Speak(textBox.Text);
     ss.SetOutputToDefaultAudioDevice();
     MessageBox.Show("Recording Complete", "Report");
 }
Exemplo n.º 54
0
        static void Main(params string[] args)
        {
            DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_BYCOMMAND);
            Console.CursorVisible = false;
            Console.TreatControlCAsInput = true;
            Console.WindowHeight = 60;
            Console.WindowWidth = 60;
            Console.BufferHeight = Console.WindowHeight;
            Console.BufferWidth = Console.WindowWidth;

            try
            {
                autonomous_toshko = bool.Parse(
                    ConfigurationManager.AppSettings["autonomous_toshko"]);
                min_delay = int.Parse(
                    ConfigurationManager.AppSettings["min_delay"]);
                max_delay = int.Parse(
                    ConfigurationManager.AppSettings["max_delay"]);
            }
            catch
            { }

            using (SpeechSynthesizer synth = new SpeechSynthesizer() { Volume = speechVolume, Rate = speechRate })
            {
                synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Teen);

                while (true)
                {
                    Console.Clear();
                    int randomIndex = Rnd.Next(0, ToshkoPhrases.Length);
                    string consoleOutput = ToshkoPhrases[randomIndex];
                    Console.WriteLine(consoleOutput);
                    Console.WriteLine(ToshkoAscii);
                    Console.Title = consoleOutput;
                    synth.Speak(ToshkoPhrasesEnglishized[randomIndex]);

                    if (autonomous_toshko)
                        Thread.Sleep(Rnd.Next(min_delay, max_delay));
                    else
                    {
                        Console.WriteLine("Press enter to continue");
                        Console.ReadLine();
                    }
                }
            }
        }
Exemplo n.º 55
0
        /// <summary>
        /// 语音提示
        /// <summary>
        public void sayword(string strAlarm)
        {
            try
            {
                SpeechSynthesizer Talker = new SpeechSynthesizer();
                Talker.Rate = 2;//控制语速(-10--10)
                Talker.Volume = 100;//控制音量

                #region 获取本机上所安装的所有的Voice的名称
                //string voicestring = "";

                //foreach (InstalledVoice iv in Talker.GetInstalledVoices())
                //{
                //    voicestring += iv.VoiceInfo.Name + ",";
                //}
                //Microsoft Mary,Microsoft Mike,Microsoft Sam,Microsoft Simplified Chinese,SampleTTSVoice
                //Talker.SelectVoice("Microsoft Mary");
                #endregion

                //Talker.SetOutputToWaveFile("c:\soundfile.wav");//读取文件

                Talker.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Child, 2, System.Globalization.CultureInfo.CurrentCulture);
                Talker.SpeakAsync(strAlarm);
            }
            catch (Exception ex)
            {
                Log.WriteLog("语音提示控件" + ex.ToString());
            }
        }
Exemplo n.º 56
0
        async void InitQuran()
        {

            //setup state
            CurrentState = new QuranState();

            //setup data from config
            CurrentState.config = new Konfigurasi();
            CurrentState.Ayah = CurrentState.config.AyahLastOpen;
            CurrentState.Surah = CurrentState.config.SurahLastOpen;
            CurrentState.LanguageId = CurrentState.config.LanguageLastOpen;
            CurrentState.ReciterId = CurrentState.config.ReciterLastOpen;
            CurrentState.Juz = CurrentState.config.JuzLastOpen;

            //speech synth
            speechSynthesizer = new SpeechSynthesizer();
            speechSynthesizer.SelectVoiceByHints(VoiceGender.Female);
            speechSynthesizer.Volume = Convert.ToInt32(CurrentState.config.Volume * 100);
            speechSynthesizer.SpeakCompleted += speechSynthesizer_SpeakCompleted;

            //setup setting
            CurrentState.CtlSetting = new ListSetting();
            ExpanderSetting.Content = CurrentState.CtlSetting;
            //get configuration from config
            CurrentState.CtlSetting.setVolume(CurrentState.config.Volume);
            CurrentState.CtlSetting.setVerseSize(CurrentState.config.VerseSize);
            CurrentState.CtlSetting.setClickMode(CurrentState.config.ClickMode);
            CurrentState.CtlSetting.setPlayMode(CurrentState.config.PlayMode);
            CurrentState.CtlSetting.setVoice(CurrentState.config.isVoiceEnable);
            CurrentState.CtlSetting.setGesture(CurrentState.config.isGestureEnable);
            CurrentState.CtlSetting.setAutoShutdown(CurrentState.config.isAutoShutdownEnable);
            CurrentState.CtlSetting.VerseChangeEvent += CtlSetting_VerseChangeEvent;
            CurrentState.CtlSetting.VolumeChangeEvent += CtlSetting_VolumeChangeEvent;

            //setup expander
            var Jz = BLL.quran_data.getJuz(CurrentState.Juz);
            setExpanderTitle(ExpanderJuz, "Juzlbl", "Selected Juz: " + Jz.idx + ". " + Jz.name);

            var Rct = BLL.quran_data.getReciter(CurrentState.ReciterId);
            setExpanderTitle(ExpanderReciter, "Reciterlbl", Rct.name);

            var Lng = BLL.quran_data.getLanguage(CurrentState.LanguageId);
            setExpanderTitle(ExpanderLanguage, "Langlbl", Lng.lang);

            //player state
            CurrentState.isPlaying = false;
            QuranPlayer.LoadedBehavior = MediaState.Manual;
            QuranPlayer.UnloadedBehavior = MediaState.Stop;
            //QuranPlayer.Volume = CurrentState.config.Volume;
            QuranPlayer.Stop();
            Binding volBInding = new Binding("Volume");
            volBInding.Source = CurrentState.CtlSetting;
            QuranPlayer.SetBinding(MediaElement.VolumeProperty, volBInding);

            //setup language
            CurrentState.CtlLanguage = new ListLanguage();
            CurrentState.CtlLanguage.Height = 250;
            CurrentState.CtlLanguage.LanguageSelectEvent += CtlLanguage_LanguageSelectEvent;
            ExpanderLanguage.Content = CurrentState.CtlLanguage;

            //setup reciter
            CurrentState.CtlReciter = new ListReciter();
            CurrentState.CtlReciter.Height = 250;
            CurrentState.CtlReciter.ReciterSelectEvent += CtlReciter_ReciterSelectEvent;
            ExpanderReciter.Content = CurrentState.CtlReciter;

            //setup juz
            CurrentState.CtlJuz = new ListJuz();
            CurrentState.CtlJuz.Height = 250;
            CurrentState.CtlJuz.JuzSelectEvent += CtlJuz_JuzSelectEvent;
            ExpanderJuz.Content = CurrentState.CtlJuz;

            //setup surah
            CurrentState.CtlSurah = new ListSurah();
            CurrentState.CtlSurah.SurahSelectEvent += CtlSurah_SurahSelectEvent;
            CurrentState.CtlSurah.Height = 250;
            ExpanderSurah.Content = CurrentState.CtlSurah;
            CurrentState.CtlSurah.LoadSurah(CurrentState.Juz);

            //setup ayah
            CurrentState.CtlAyah = new ListAyah();
            CurrentState.CtlAyah.AyahSelectEvent += CtlAyah_AyahSelectEvent;

            AyahPanel.Children.Add(CurrentState.CtlAyah);

            //select last opened ayah
            LoadSpecificSurah(CurrentState.Surah, CurrentState.Ayah);
            CurrentState.CtlAyah.SetItemAyah(CurrentState.Ayah - 1, Brushes.Red, true, false);

            //load bookmark
            CurrentState.CtlBookmark = new ListBookmark();
            CurrentState.CtlBookmark.BookmarkSelectEvent += CtlBookmark_BookmarkSelectEvent;
            CurrentState.CtlBookmark.Height = 250;
            ExpanderBookmark.Content = CurrentState.CtlBookmark;

            //Internet check
            InternetState = await QFE.WPF.Tools.Internet.CheckConnection(CurrentState.config.UrlRecitation);
            if (!InternetState) MessageBox.Show("No Internet connection.", "Warning");

        }
Exemplo n.º 57
0
        protected Boolean InitializeSynth()
        {
            try
            {
                synthResponses.Add("Yes sir");
                synthResponses.Add("Alright");
                synthResponses.Add("Done sir");

                synth = new SpeechSynthesizer();
                synth.SetOutputToDefaultAudioDevice();
                synth.SelectVoiceByHints(VoiceGender.Male, VoiceAge.Child);

                synth.Speak("Kinect AR drone initializing...");
                synth.Speak("Say ... DRONE, to enable voice command");

                return true;
            }
            catch (Exception e)
            {
                return false;
            }

        }
Exemplo n.º 58
0
        private void TextToSpeech()
        {
            try
            {
                SpeechSynthesizer synth = new SpeechSynthesizer();
                synth.SetOutputToDefaultAudioDevice();
                synth.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Teen);
                synth.Rate = -4;
                synth.Volume = 100;

                synth.SpeakAsyncCancelAll();
                synth.SpeakAsync(TextToSpeak);
            }
            catch(Exception ex) {
                using (StreamWriter w = File.AppendText("log.txt"))
                {
                    Log(ex.Message, w);
                }
            }
        }
Exemplo n.º 59
0
        public void Show(GlobalManager oldgm)
        {
            gm = oldgm;
            gm.ChangeTransportWindow("PlayNow");

            //set team name and shadow
            uiTeamAName.Text = gm.ms.TeamAName;
            uiTeamBName.Text = gm.ms.TeamBName;

            string myself = "";
            foreach (Player item in gm.gamePlayerList) {
                if (item.PlayerName == gm.gameSettings.playerName) { myself = item.PlayerGroupName; break; }
            }

            if (myself == gm.ms.TeamAName) {
                uiTeamAShadow.Color = Color.FromArgb(255, 0, 0, 255);
                uiTeamBShadow.Color = Color.FromArgb(255, 255, 0, 0);
            } else {
                uiTeamAShadow.Color = Color.FromArgb(255, 255, 0, 0);
                uiTeamBShadow.Color = Color.FromArgb(255, 0, 0, 255);
            }

            //以talk模式拦截-拦过了,继承拦截
            //gm.kh.SetHook(false);

            gm.PlayNow_inputPlayerData = new Action<StringGroup>(inputPlayerData);
            gm.PlayNow_playerDied = new Action<string>(playerDied);
            gm.PlayNow_playerSuccess = new Action<string>(playerSuccess);
            gm.PlayNow_teamDied = new Action<string>(teamDied);
            gm.PlayNow_turnToNewWindow = new Action(turnToNewWindow);
            gm.PlayNow_newMessage = new Action<string>(newMessage);

            //show player
            var playerSplit = from item in gm.gamePlayerList
                              where item.PlayerGroupName != ""
                              group item by item.PlayerGroupName;
            foreach (var item in playerSplit) {
                if (item.Key == gm.ms.TeamAName) {
                    uiTeamAList.ItemsSource = item.ToList<Player>();
                } else {
                    uiTeamBList.ItemsSource = item.ToList<Player>();
                }
            }

            stopTurnIn = false;
            stopShowPrize = false;
            talkList = new List<TalkListItem>();
            prizeLine = new Queue<PrizeStructure>();

            this.Show();

            //数据传输的操作
            Task.Run(async () =>
               {

               SpeechSynthesizer speakStart = new SpeechSynthesizer();
               speakStart.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);

               uiTimer.Dispatcher.Invoke(() => { uiTimer.Text = "20"; });

               //显示欢迎来到
               uiNoticeText.Dispatcher.Invoke(() => { uiNoticeText.Text = "欢迎来到Ballance的世界"; });
               speakStart.SpeakAsync("欢迎来到Ballance的世界");

               for (int i = 0; i < 5; i++) {
                   Thread.Sleep(1000);
                   uiTimer.Dispatcher.Invoke(() => { uiTimer.Text = (int.Parse(uiTimer.Text) - 1).ToString(); });
               }

               //此时=15
               //显示负责的关卡
               foreach (Player item in gm.gamePlayerList) {
                   if (item.PlayerName == gm.gameSettings.playerName) {
                       uiNoticeText.Dispatcher.Invoke(() => { uiNoticeText.Text = "你的任务:完成" + item.DutyUnitToString + "小节,请在这些小节好好表现"; });
                       speakStart.SpeakAsync("鼓足干劲,力争上游");
                   }
               }

               for (int i = 0; i < 10; i++) {
                   Thread.Sleep(1000);
                   uiTimer.Dispatcher.Invoke(() => { uiTimer.Text = (int.Parse(uiTimer.Text) - 1).ToString(); });
               }

               //此时=5
               //准备开始
               uiNoticeText.Dispatcher.Invoke(() => { uiNoticeText.Text = "请就绪"; });
               speakStart.SpeakAsync("还有五秒开始游戏");

               for (int i = 0; i < 5; i++) {
                   Thread.Sleep(1000);
                   uiTimer.Dispatcher.Invoke(() => { uiTimer.Text = (int.Parse(uiTimer.Text) - 1).ToString(); });
               }

               //隐藏
               uiTimerContainer.Dispatcher.Invoke(() => { uiTimerContainer.Visibility = Visibility.Collapsed; });
               //全军出击
               uiNoticeText.Dispatcher.Invoke(() => { uiNoticeText.Text = ""; });
               uiNotice.Dispatcher.Invoke(() => { uiNotice.Visibility = Visibility.Hidden; });
               speakStart.SpeakAsync("全军出击");

               //提交循环
               long previousMark = 1000;
               int similarityCount = 20;
               //是否达到极限溢出了
               bool overCount = false;
               while (true) {

                   if (stopTurnIn == true) { break; }

                   long mark = gm.markMonitor.Mode(await gm.markMonitor.ReadDataAsync());
                   long life = gm.lifeMonitor.Mode(await gm.lifeMonitor.ReadDataAsync());
                   long unit = gm.unitMonitor.Mode(await gm.unitMonitor.ReadDataAsync());

                   gm.dataGiveIn.SendData(CombineAndSplitSign.Combine(BallanceOnline.Const.ClientAndServerSign.Client, BallanceOnline.Const.SocketSign.GameDataTurnIn, mark.ToString() + "," + life.ToString() + "," + unit.ToString()));

                   //如果有相同情况出现,提醒警告
                   if (overCount == false) {
                       if (previousMark == mark) {
                           similarityCount--;
                           //检查超限
                           if (similarityCount < 0) {
                               uiTimer.Dispatcher.Invoke(() => { uiTimer.Text = ""; });
                               uiTimerContainer.Dispatcher.Invoke(() => { uiTimerContainer.Visibility = Visibility.Collapsed; });
                               overCount = true;
                           } else {
                               uiTimer.Dispatcher.Invoke(() => { uiTimer.Text = similarityCount.ToString(); });
                               uiTimerContainer.Dispatcher.Invoke(() => { uiTimerContainer.Visibility = Visibility.Visible; });
                           }

                       } else {
                           if (similarityCount != 20) {
                               similarityCount = 20;
                               uiTimer.Dispatcher.Invoke(() => { uiTimer.Text = ""; });
                               uiTimerContainer.Dispatcher.Invoke(() => { uiTimerContainer.Visibility = Visibility.Collapsed; });
                           }
                       }
                   }

                   previousMark = mark;

                   Thread.Sleep(1000);

               }

               speakStart.Dispose();

               //结束

               });

            //显示成就的操作
            Task.Run(() =>
            {
                while (true) {
                    if (stopShowPrize == true) { break; }
                    if (prizeLine.Count == 0) { Thread.Sleep(500); continue; }

                    //展示
                    var cache = prizeLine.Dequeue();
                    string sayWord = "";
                    string showWord = cache.PlayerName + " ";

                    switch (cache.PrizeName) {
                        case GamePrize.FirstBlood:
                            showWord += GamePrize.FirstBloodShow;
                            sayWord = GamePrize.FirstBloodSpeech;
                            break;
                        case GamePrize.Reborn:
                            showWord += GamePrize.RebornShow;
                            sayWord = GamePrize.RebornSpeech;
                            break;
                        case GamePrize.Silence:
                            showWord += GamePrize.SilenceShow;
                            sayWord = GamePrize.SilenceSpeech;
                            break;
                        case GamePrize.Time:
                            showWord += GamePrize.TimeShow;
                            sayWord = GamePrize.TimeSpeech;
                            break;
                        case GamePrize.Ace:
                            showWord += GamePrize.AceShow;
                            sayWord = GamePrize.AceSpeech;
                            break;
                    }

                    //show
                    uiNoticeText.Dispatcher.Invoke(() =>
                    {
                        uiNoticeText.Text = showWord;
                    });
                    uiNotice.Dispatcher.Invoke(() =>
                    {
                        uiNotice.Visibility = Visibility.Visible;
                    });

                    //say
                    SpeechSynthesizer speak = new SpeechSynthesizer();
                    speak.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
                    speak.Speak(sayWord);
                    speak.Dispose();

                    //hide
                    uiNotice.Dispatcher.Invoke(() =>
                    {
                        uiNotice.Visibility = Visibility.Visible;
                    });
                }

            });
        }
Exemplo n.º 60
-1
        static void Main(string[] args)
        {
            #region Performance counters
            // This will pull the current CPU load in percentage
            PerformanceCounter perfCountCPU = new PerformanceCounter("Processor Information", "% Processor Time", "_Total");
            perfCountCPU.NextValue();

            // This will pull the current available memory in Megabytes
            PerformanceCounter perfCountMem = new PerformanceCounter("Memory", "Available MBytes");
            perfCountMem.NextValue();

            // This will get us the system up time (in seconds)
            PerformanceCounter perfCountUpTime = new PerformanceCounter("System", "System Up Time");
            perfCountUpTime.NextValue();

            #endregion
            // This will greet the user in the default voice
            SpeechSynthesizer synth = new SpeechSynthesizer();
            synth.Speak("This is CPU and Memory monitor");
            synth.Speak("Hello, how are you today?");

            synth.SelectVoiceByHints(VoiceGender.Female);
            TimeSpan uptime = TimeSpan.FromSeconds(perfCountUpTime.NextValue());
            string UpTimeMessage = String.Format("The current system up time is {0} days, {1} hours, {2} minutes and {3} seconds", (int)uptime.TotalDays, (int)uptime.Hours, (int)uptime.Minutes, (int)uptime.Seconds);
            Console.WriteLine(UpTimeMessage);
            synth.Speak(UpTimeMessage);

            while (true)
            {
                int currentCpuPercentage = (int)perfCountCPU.NextValue();
                int currentAvailableMemory = (int)perfCountMem.NextValue();

                // Every 1 second print the CPU load in percentage to the screen
                Console.WriteLine("CPU load %: {0}", currentCpuPercentage);
                Console.WriteLine("Available Memory: {0}MB", currentAvailableMemory);

                if (currentCpuPercentage > 80)
                {
                    if (currentCpuPercentage == 100)
                    {
                        synth.SelectVoiceByHints(VoiceGender.Female);
                        synth.Speak("Warning, warning CPU load is 100 percent!");
                    }
                    else
                    {
                        string cpuLoadMessage = String.Format("The current CPU load is {0} percent", currentCpuPercentage);
                        synth.Speak(cpuLoadMessage);
                    }

                }

                if (currentAvailableMemory < 1024)
                {
                    string MemoryMessage = String.Format("The current available memory is {0} megabytes", currentAvailableMemory);
                    synth.Speak(MemoryMessage);
                }

                Thread.Sleep(1000);
            }
        }