Ejemplo n.º 1
0
        public void initRS()
        {
            try
            {
                SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new CultureInfo("en-US"));

                var words = new Choices();
                words.Add("Hello");
                words.Add("Jump");
                words.Add("Left");
                words.Add("Right");

                var gb = new GrammarBuilder();
                gb.Culture = new System.Globalization.CultureInfo("en-US");
                gb.Append(words);
                Grammar g = new Grammar(gb);

                sre.LoadGrammar(g);
                
                sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
                sre.SetInputToDefaultAudioDevice();
                sre.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch (Exception e)
            {
                label1.Text = "init RS Error : " + e.ToString();
            }
        }
Ejemplo n.º 2
0
        public Grammar BuildGrammar()
        {
            Choices choiceBuilder = new Choices();

            // Songs
            if (SongHelper.SongCount() > 0) // it freaks out if there's nothing in the one-of bit.
            {
                GrammarBuilder songBuilder = new GrammarBuilder();
                songBuilder.Append("play song");
                songBuilder.Append(SongHelper.GenerateSongChoices());
                choiceBuilder.Add(songBuilder);
            }

            GrammarBuilder shuffleBuilder = new GrammarBuilder();
            shuffleBuilder.Append("shuffle all songs");
            choiceBuilder.Add(shuffleBuilder);

            // Playlists
            if (SongHelper.PlaylistCount() > 0)
            {
                GrammarBuilder playListBuilder = new GrammarBuilder();
                playListBuilder.Append("play playlist");
                playListBuilder.Append(SongHelper.GeneratePlaylistChoices());
                choiceBuilder.Add(playListBuilder);

                GrammarBuilder shufflePlayListBuilder = new GrammarBuilder();
                shufflePlayListBuilder.Append("shuffle playlist");
                shufflePlayListBuilder.Append(SongHelper.GeneratePlaylistChoices());
                choiceBuilder.Add(shufflePlayListBuilder);
            }

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

            return gram;
        }
Ejemplo n.º 3
0
        public Grammar BuildGrammar()
        {
            Choices choiceBuilder = new Choices();

            // Next
            GrammarBuilder nextBuilder = new GrammarBuilder();
            nextBuilder.Append(new Choices("next song", "play the next song", "skip this song", "play next song"));
            choiceBuilder.Add(nextBuilder);

            // Previous
            GrammarBuilder prevBuilder = new GrammarBuilder();
            prevBuilder.Append(new Choices("last song", "previous song", "play the last song", "play the previous song"));
            choiceBuilder.Add(prevBuilder);

            // Pause
            GrammarBuilder pauseBuilder = new GrammarBuilder();
            pauseBuilder.Append(new Choices("pause song", "pause this song", "pause song playback"));
            choiceBuilder.Add(pauseBuilder);

            // Stop
            GrammarBuilder stopBuilder = new GrammarBuilder();
            stopBuilder.Append(new Choices("stop song", "stop song playback", "stop the music"));
            choiceBuilder.Add(stopBuilder);

            // Resume
            GrammarBuilder resumeBuilder = new GrammarBuilder();
            resumeBuilder.Append(new Choices("resume playback", "resume song", "resume playing"));
            choiceBuilder.Add(resumeBuilder);

            return new Grammar(new GrammarBuilder(choiceBuilder));
        }
Ejemplo n.º 4
0
 /*
  * Función: GetGrammar
  * Descripción: Función que llena y devuelve la gramática usando los vectores de comandos y el árbol de comandos
  * Autor: Christian Vargas
  * Fecha de creación: 16/08/15
  * Fecha de modificación: --/--/--
  * Entradas: Nodo inicial del árbol de comandos
  * Salidas: (Choices, gramática para entrenar a Kinect)
  */
 public static Choices GetGrammar(CommandNode commandTree)
 {
     grammar = new Choices();
     grammar.Add(UNLOCK_COMMAND);
     foreach (string command in GEOMETRIC_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string command in MENU_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string command in DICTATION_COMMANDS)
     {
         grammar.Add(command);
     }
     foreach (string characterSound in CHARACTERS_SOUNDS)
     {
         grammar.Add(characterSound);
     }
     foreach (string characterSound in ALT_CHARACTERS_SOUNDS)
     {
         grammar.Add(characterSound);
     }
     AddNodeToGrammar(commandTree);
     AddNumbers();
     return grammar;
 }
Ejemplo n.º 5
0
        public IntroGrammar()
        {
            Choices majors = new Choices();
             majors.Add(new SemanticResultValue("Computer Science", "CSC"));

             SemanticResultKey majorKey = new SemanticResultKey(Slots.Major.ToString(), majors);

             Choices years = new Choices();
             for (int i = 2001; i < 2020; i++)
             {
            years.Add(new SemanticResultValue(i.ToString(), i));
             }
             SemanticResultKey year = new SemanticResultKey(Slots.GradYear.ToString(), years);

             Choices yesOrNo = new Choices();
             yesOrNo.Add(new SemanticResultValue("yes", "yes"));
             yesOrNo.Add(new SemanticResultValue("yeah", "yes"));
             yesOrNo.Add(new SemanticResultValue("yep", "yes"));
             yesOrNo.Add(new SemanticResultValue("no", "no"));
             yesOrNo.Add(new SemanticResultValue("nope", "no"));
             SemanticResultKey yesNo = new SemanticResultKey(Slots.YesNo.ToString(), yesOrNo);

             Choices options = new Choices();
             options.Add(majorKey);
             options.Add(year);
             options.Add(yesNo);

             GrammarBuilder builder = new GrammarBuilder();
             builder.Append(options);
             grammar = new Grammar(builder);
        }
void BuildSpeechEngine(RecognizerInfo rec)
{
    _speechEngine = new SpeechRecognitionEngine(rec.Id);

    var choices = new Choices();
    choices.Add("venus");
    choices.Add("mars");
    choices.Add("earth");
    choices.Add("jupiter");
    choices.Add("sun");

    var gb = new GrammarBuilder { Culture = rec.Culture };
    gb.Append(choices);

    var g = new Grammar(gb);

    _speechEngine.LoadGrammar(g);
    //recognized a word or words that may be a component of multiple complete phrases in a grammar.
    _speechEngine.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(SpeechEngineSpeechHypothesized);
    //receives input that matches any of its loaded and enabled Grammar objects.
    _speechEngine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(_speechEngineSpeechRecognized);
    //receives input that does not match any of its loaded and enabled Grammar objects.
    _speechEngine.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(_speechEngineSpeechRecognitionRejected);


    //C# threads are MTA by default and calling RecognizeAsync in the same thread will cause an COM exception.
    var t = new Thread(StartAudioStream);
    t.Start();
}
Ejemplo n.º 7
0
        public VoiceInput()
        {
            recognizer = new SpeechRecognitionEngine(new CultureInfo("en-US"));

            recognizer.SetInputToDefaultAudioDevice();
            Choices choices = new Choices();
            foreach (String command in commands)
            {
                choices.Add(command);
            }
            choices.Add(startListening);
            choices.Add(stopListening);
            choices.Add(stop);
            /*choices.Add("Close");
            choices.Add("Left");
            choices.Add("Right");
            choices.Add("Tilt Left");
            choices.Add("Tilt Right");
            choices.Add("Move");
            choices.Add("Back");
            choices.Add("Move Up");
            choices.Add("Down");
            choices.Add("Exit");
            choices.Add("Stop");
            choices.Add("Start Listening");
            choices.Add("Stop Listening");*/
            Grammar grammar = new Grammar(new GrammarBuilder(choices));
            recognizer.LoadGrammar(grammar);

            recognizer.SpeechRecognized +=
                new EventHandler<SpeechRecognizedEventArgs>(SpeechRecognized);
            recognizer.RecognizeAsync(RecognizeMode.Multiple);
        }
Ejemplo n.º 8
0
        public Main()
        {
            InitializeComponent();

            fontList.SelectedIndex = 0;
            squareCenter = squareButton.Checked;

            speechEngine.SpeechRecognized +=new EventHandler<SpeechRecognizedEventArgs>(speechEngine_SpeechRecognized);

            speechEngine.SetInputToDefaultAudioDevice();

            Choices choices = new Choices("primes", "squares", "dots", "numbers");

            foreach(string item in fontList.Items)
                choices.Add("set font " + item);

            for (int i = 0; i <= 999; ++i)
                choices.Add("set size " + i);

            GrammarBuilder grammarBuilder = new GrammarBuilder(choices);
            speechEngine.LoadGrammar(new Grammar(grammarBuilder));
            speechEngine.RecognizeAsync(RecognizeMode.Multiple);

            init();
        }
Ejemplo n.º 9
0
        private GrammarBuilder addCommand()
        {
            //<pleasantries> <command> <CLASS> <prep> <Time><year>
             //Pleasantries: I'd like to, please, I want to, would you
             //Command: Add, Remove
             //Class: a class, this class, that class, that other class
             //When: to Spring 2012

             Choices commands = new Choices();
             SemanticResultValue commandSRV;
             commandSRV = new SemanticResultValue("add", (int)CommandTypes.Add);
             commands.Add(commandSRV);
             commandSRV = new SemanticResultValue("take", (int)CommandTypes.Add);
             commands.Add(commandSRV);
             commandSRV = new SemanticResultValue("put", (int)CommandTypes.Add);
             commands.Add(commandSRV);
             SemanticResultKey commandSemKey = new SemanticResultKey(Slots.Command.ToString(), commands);

             // put the whole command together
             GrammarBuilder finalCommand = new GrammarBuilder();
             finalCommand.Append(this.pleasantries, 0, 1);
             finalCommand.Append(commandSemKey);
             finalCommand.Append(this.course, 0, 1);
             finalCommand.Append(this.semester, 0, 1);

             return finalCommand;
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            try
            {
                ss.SetOutputToDefaultAudioDevice();
                Console.WriteLine("\n(Speaking: I am awake)");
                ss.Speak("I am awake");

                CultureInfo ci = new CultureInfo("en-us");
                sre = new SpeechRecognitionEngine(ci);
                sre.SetInputToDefaultAudioDevice();
                sre.SpeechRecognized += sre_SpeechRecognized;

                Choices ch_StartStopCommands = new Choices();
                ch_StartStopCommands.Add("Alexa record");
                ch_StartStopCommands.Add("speech off");
                ch_StartStopCommands.Add("klatu barada nikto");
                GrammarBuilder gb_StartStop = new GrammarBuilder();
                gb_StartStop.Append(ch_StartStopCommands);
                Grammar g_StartStop = new Grammar(gb_StartStop);

                sre.LoadGrammarAsync(g_StartStop);
                sre.RecognizeAsync(RecognizeMode.Multiple); // multiple grammars

                while (done == false) { ; }

                Console.WriteLine("\nHit <enter> to close shell\n");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
Ejemplo n.º 11
0
        public void CreateGrammar()
        {
            // 1[what]  2[is today's, is tomorrow's, is the] 3[is today, is tomorrow]  4[time, day, date]  5[is it]

            var one = new Choices();
            one.Add(new SemanticResultValue("what", "what"));
            var sOne = new SemanticResultKey("one", one);

            var two = new Choices();
            two.Add(new SemanticResultValue("is today's", "is today"));
            two.Add(new SemanticResultValue("is tomorrow's", "is tomorrow"));
            two.Add(new SemanticResultValue("is the", "is the"));
            var sTwo = new SemanticResultKey("two", two);

            var three = new Choices();
            three.Add(new SemanticResultValue("is today", "is today"));
            three.Add(new SemanticResultValue("is tomorrow", "is tomorrow"));
            three.Add(new SemanticResultValue("was yesterday", "was yesterday"));
            var sThree = new SemanticResultKey("three", three);

            var four = new Choices();
            four.Add(new SemanticResultValue("time", "time"));
            four.Add(new SemanticResultValue("day", "day"));
            four.Add(new SemanticResultValue("date", "day"));
            var sFour = new SemanticResultKey("three", four);

            var five = new Choices();
            five.Add(new SemanticResultValue("is it", "is it"));
            var sFive = new SemanticResultKey("four", five);

            // what (time, day, date) is it
            var gOne = new GrammarBuilder();
            gOne.Append(sOne);
            gOne.Append(sFour);
            gOne.Append(sFive);

            // what (is today's, is the) (time, day, date)
            var gTwo = new GrammarBuilder();
            gTwo.Append(sOne);
            gTwo.Append(sTwo);
            gTwo.Append(sFour);

            // what (is today, is tomorrow)
            var gThree = new GrammarBuilder();
            gThree.Append(sOne);
            gThree.Append(sThree);

            var perm = new Choices();
            perm.Add(gOne);
            perm.Add(gTwo);
            perm.Add(gThree);

            var b = new GrammarBuilder();
            b.Append(perm, 0, 1);

            Grammar = new Grammar(b);
        }
Ejemplo n.º 12
0
        static void Main(string[] args)
        {                    
            using (var source = new KinectAudioSource())
            {
                source.FeatureMode = true;
                source.AutomaticGainControl = false; //Important to turn this off for speech recognition
				source.SystemMode = SystemMode.OptibeamArrayOnly; //No AEC for this sample

                RecognizerInfo ri = GetKinectRecognizer();

                if (ri == null)
                {
                    Console.WriteLine("Could not find Kinect speech recognizer. Please refer to the sample requirements.");
                    return;
                }

                Console.WriteLine("Using: {0}", ri.Name);

                using (var sre = new SpeechRecognitionEngine(ri.Id))
                {                
                    var colors = new Choices();
                    colors.Add("red");
                    colors.Add("green");
                    colors.Add("blue");

                    var gb = new GrammarBuilder();
                    //Specify the culture to match the recognizer in case we are running in a different culture.                                 
                    gb.Culture = ri.Culture;
                    gb.Append(colors);
                    

                    // Create the actual Grammar instance, and then load it into the speech recognizer.
                    var g = new Grammar(gb);                    

                    sre.LoadGrammar(g);
                    sre.SpeechRecognized += SreSpeechRecognized;
                    sre.SpeechHypothesized += SreSpeechHypothesized;
                    sre.SpeechRecognitionRejected += SreSpeechRecognitionRejected;

                    using (Stream s = source.Start())
                    {
                        sre.SetInputToAudioStream(s,
                                                  new SpeechAudioFormatInfo(
                                                      EncodingFormat.Pcm, 16000, 16, 1,
                                                      32000, 2, null));

						Console.WriteLine("Recognizing. Say: 'red', 'green' or 'blue'. Press ENTER to stop");

                        sre.RecognizeAsync(RecognizeMode.Multiple);
                        Console.ReadLine();
                        Console.WriteLine("Stopping recognizer ...");
                        sre.RecognizeAsyncStop();                       
                    }
                }
            }
        }
 public void loadCommandGrammar()
 {
     var keywords = _settingsList.Commands.Select(coms => coms.VoiceKeyword);
     Choices sList = new Choices();
     sList.Add(keywords.ToArray());
     sList.Add("start dictation");
     sList.Add("start scroll");
     sList.Add("stop scroll");
     GrammarBuilder gb = new GrammarBuilder(sList);
     commandGrammar = new Grammar(gb);
 }
Ejemplo n.º 14
0
        public The_Road_To_100()
        {
            InitializeComponent();
            PmainManu.BringToFront();
            PmainManu.Dock = DockStyle.Fill;
            organizeMenu();

            if (Directory.Exists(@"C:\The Road To 100\user.ID 1"))
            {
                setPersonal_Screen();
                Bcontinue.Enabled = true;
            }
            else
            {
                DirectoryInfo di = Directory.CreateDirectory(@"C:\The Road To 100");
                di.Create();
                di.Attributes = FileAttributes.Directory | FileAttributes.Hidden;

            }
            Choices commands = new Choices();
            commands.Add(new string[] { "start", "finish", "close" });
            GrammarBuilder GB = new GrammarBuilder();
            GB.Append(commands);
            Grammar grammar = new Grammar(GB);

            sre.LoadGrammarAsync(grammar);
            sre.SetInputToDefaultAudioDevice();
            sre.SpeechRecognized += sre_src;
        }
        private void Window1_Load()
        {

           

       
            obj.SpeakAsync("hello, Please Choose the Model of car....");
            // Create a simple grammar that recognizes "red", "green", or "blue".
            Choices models = new Choices();
            models.Add(new string[] { "toyota", "suzuki", "honda", "kia","bmw"});

            // Create a GrammarBuilder object and append the Choices object.
            GrammarBuilder gb = new GrammarBuilder();


            gb.Append(models);

            // Create the Grammar instance and load it into the speech recognition engine.
            Grammar g = new Grammar(gb);
            recognizer.LoadGrammar(g);
           recognizer.Enabled= true; 
            // Register a handler for the SpeechRecognized event.
            recognizer.SpeechRecognized +=
              new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        
        }
Ejemplo n.º 16
0
 static RecogPlay()
 {
     _choices = new Choices();
     foreach (var p in _paths)
         foreach (var d in Directory.GetDirectories(p.Value))
             _choices.Add(new SemanticResultValue(Listen.CleanPath(d), Path.GetFileName(d) + "|" + p.Key + "|" + d));
 }
Ejemplo n.º 17
0
        private Grammar BrightnessGrammar()
        {
            // Change/Set Brightness to Choices
            var choices = new Choices();
            for (var i = -255; i <= 255; i++)
            {
                SemanticResultValue choiceResultValue = new SemanticResultValue(i.ToString(), i);
                GrammarBuilder resultValueBuilder = new GrammarBuilder(choiceResultValue);
                choices.Add(resultValueBuilder);
            }

            GrammarBuilder changeGrammar = "Change";
            GrammarBuilder setGrammar = "Set";
            GrammarBuilder brightnessGrammar = "Brightness";
            GrammarBuilder toGrammar = "To";

            SemanticResultKey resultKey = new SemanticResultKey("brightness", choices);
            GrammarBuilder resultContrast = new GrammarBuilder(resultKey);

            Choices alternatives = new Choices(changeGrammar, setGrammar);

            GrammarBuilder result = new GrammarBuilder(alternatives);
            result.Append(brightnessGrammar);
            result.Append(toGrammar);
            result.Append(resultContrast);

            Grammar grammar = new Grammar(result);
            grammar.Name = "Set Brightness";
            return grammar;
        }
Ejemplo n.º 18
0
        public override void Initiate(IEnumerable<string> commandKeys)
        {
            var choices = new Choices();
            choices.Add(commandKeys.ToArray());
            var gr = new Grammar(new GrammarBuilder(choices));
            _mainSpeechRecognitionEngine.RequestRecognizerUpdate();
            _mainSpeechRecognitionEngine.LoadGrammar(gr);
            _mainSpeechRecognitionEngine.SpeechRecognized += _mainSpeechRecognitionEngine_SpeechRecognized;

            try
            {
                _mainSpeechRecognitionEngine.SetInputToDefaultAudioDevice();
            }
            catch (Exception exception)
            {
                base.WriteLine(string.Format("Unable to set default input audio device. Error: {0}", exception.Message), OutputLevel.Error, null);
                return;
            }

            var subChoices = new Choices();
            subChoices.Add(new[] { "tab", "enter" });
            var subGr = new Grammar(new GrammarBuilder(subChoices));
            _subSpeechRecognitionEngine.RequestRecognizerUpdate();
            _subSpeechRecognitionEngine.LoadGrammar(subGr);
            _subSpeechRecognitionEngine.SpeechRecognized += _subSpeechRecognitionEngine_SpeechRecognized;
            _subSpeechRecognitionEngine.SetInputToDefaultAudioDevice();
        }
        internal void LoadCurrentSyllabus(SyllabusTracker syllabusTracker)
        {
            if (_speechRecognitionEngine == null) return; // not currently running recognition

            _speechRecognitionEngine.RequestRecognizerUpdate();
            _speechRecognitionEngine.UnloadAllGrammars();

            // new choices consolidation for commands - one command per syllabus file line
            var commandLoad = new Choices();
            foreach (var baseSyllabus in syllabusTracker.Syllabi)
            {
                foreach (var command in baseSyllabus.Commands)
                {
                    commandLoad.Add(command);
                }
            }

            // add commands - should be per input language, but now English
            VoiceCommands.AddCommands(commandLoad);

            var gBuilder = new GrammarBuilder();
            gBuilder.Append(commandLoad);
            var grammar = new Grammar(gBuilder) { Name = "Syllabus" };
            _speechRecognitionEngine.LoadGrammar(grammar);

            var dictgrammar = new DictationGrammar("grammar:dictation#pronunciation") { Name = "Random" };
            _speechRecognitionEngine.LoadGrammar(dictgrammar);
        }
Ejemplo n.º 20
0
        public Grammar BuildGrammar()
        {
            Choices choiceBuilder = new Choices();

            // What Song
            GrammarBuilder whatBuilder = new GrammarBuilder();
            whatBuilder.Append(new Choices("what song is this", "what is this song", "what song is playing"));
            choiceBuilder.Add(whatBuilder);

            // Who
            GrammarBuilder whoBuilder = new GrammarBuilder();
            whoBuilder.Append(new Choices("who is this song by", "who sings this"));
            choiceBuilder.Add(whoBuilder);

            return new Grammar(new GrammarBuilder(choiceBuilder));
        }
Ejemplo n.º 21
0
        public SpeechRecogniser()
        {
            RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers().Where(r => r.Id == RecognizerId).FirstOrDefault();
            if (ri == null)
                return;

            sre = new SpeechRecognitionEngine(ri.Id);

            // Build a simple grammar of shapes, colors, and some simple program control
            var instruments = new Choices();
            foreach (var phrase in InstrumentPhrases)
                instruments.Add(phrase.Key);

            var objectChoices = new Choices();
            objectChoices.Add(instruments);

            var actionGrammar = new GrammarBuilder();
            //actionGrammar.AppendWildcard();
            actionGrammar.Append(objectChoices);

            var gb = new GrammarBuilder();
            gb.Append(actionGrammar);

            var g = new Grammar(gb);
            sre.LoadGrammar(g);
            sre.SpeechRecognized += sre_SpeechRecognized;
            sre.SpeechHypothesized += sre_SpeechHypothesized;
            sre.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(sre_SpeechRecognitionRejected);

            var t = new Thread(StartDMO);
            t.Start();

            valid = true;
        }
Ejemplo n.º 22
0
        private void CreateSpeechRecongnition()
        {
            //Initialize speech recognition
            var recognizerInfo = (from a in SpeechRecognitionEngine.InstalledRecognizers()
                                  where a.Culture.Name == this.language
                                  select a).FirstOrDefault();

            if (recognizerInfo != null)
            {
                this.speechEngine = new SpeechRecognitionEngine(recognizerInfo.Id);
                Choices recognizerString = new Choices();

                recognizerString.Add(this.words);

                GrammarBuilder grammarBuilder = new GrammarBuilder();

                //Specify the culture to match the recognizer in case we are running in a different culture.
                grammarBuilder.Culture = recognizerInfo.Culture;
                grammarBuilder.Append(recognizerString);

                // Create the actual Grammar instance, and then load it into the speech recognizer.
                var grammar = new Grammar(grammarBuilder);

                //載入辨識字串
                this.speechEngine.LoadGrammarAsync(grammar);
                this.speechEngine.SpeechRecognized += SreSpeechRecognized;

                this.speechEngine.SetInputToDefaultAudioDevice();
                this.speechEngine.RecognizeAsync(RecognizeMode.Multiple);
            }
        }
Ejemplo n.º 23
0
        public Grammar BuildGrammar(RecognizerInfo recInfo, string anchor)
        {
            Choices choices = new Choices();
            this.anchor = anchor;

            // Build General Command Grammar
            choices.Add(string.Format("{0} What's the weather right now?", anchor));
            choices.Add(string.Format("{0} What's the weather for tomorrow?", anchor));
            choices.Add(string.Format("{0} What was that?", anchor));

            var gb = new GrammarBuilder();
            gb.Culture = recInfo.Culture;
            gb.Append(choices);

            return new Grammar(gb);
        }
        public void InicializeSpeechRecognize()
        {
            RecognizerInfo ri = GetKinectRecognizer();
            if (ri == null)
            {
                throw new RecognizerNotFoundException();
            }

            try
            {
                    _sre = new SpeechRecognitionEngine(ri.Id);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }

               var choises = new Choices();
            foreach(CommandSpeechRecognition cmd in _commands.Values)
            {
                choises.Add(cmd.Choise);
            }

            var gb = new GrammarBuilder {Culture = ri.Culture};
            gb.Append(choises);
            var g = new Grammar(gb);

            _sre.LoadGrammar(g);
            _sre.SpeechRecognized += SreSpeechRecognized;
            _sre.SpeechHypothesized += SreSpeechHypothesized;
            _sre.SpeechRecognitionRejected += SreSpeechRecognitionRejected;
        }
Ejemplo n.º 25
0
        //When Button 2 is clicked, it is disabled and the 'Stop' button is enabled.
        private void button2_Click(object sender, EventArgs e)
        {
            button2.Enabled = false;
            button3.Enabled = true;

            //A new set of choices is created, with which we will build a grammar.
            Choices sList = new Choices();
            //Several strings are added to an array.
            sList.Add(new string[] {"I am the dark god of Tuesday", "I wallow in the pit of always never Friday", "exit"});
            //The grammar is built using the choices.
            Grammar gr = new Grammar(new GrammarBuilder(sList));
            //We put this in an exception handler; if there are any errors, it skips over this code, and the button is reset.
            try
            {
                //This tries to pause the recogniser so that it can update.
                sRecognise.RequestRecognizerUpdate();
                //This loads the grammar.
                sRecognise.LoadGrammar(gr);
                //This handles the audio level changing.
                sRecognise.AudioLevelUpdated += new EventHandler<AudioLevelUpdatedEventArgs>(SRecognise_AudioLevelUpdated);
                //This handles speech being recognised.
                sRecognise.SpeechRecognized += SRecognise_SpeechRecognized;
                //This sets the listening microphone to the default device.
                sRecognise.SetInputToDefaultAudioDevice();
                //This creates a continuous listening mode.
                sRecognise.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch
            {
                return;
            }
        }
Ejemplo n.º 26
0
 public static SpeechRecognitionEngine getEngine(String lang)
 {
     if(init)
         recEngine.Dispose();
     Console.WriteLine("Kastat current engine");
     culture = new System.Globalization.CultureInfo(lang);
     choices = new Choices();
     grammarBuilder = new GrammarBuilder();
     VoiceCommands.Init(lang);
     choices.Add(VoiceCommands.GetAllCommands());
     grammarBuilder.Culture = culture;
     grammarBuilder.Append(choices);
     grammar = new Grammar(grammarBuilder);
     Console.WriteLine("Initialiserat svenskt grammar");
     try
     {
         recEngine = new SpeechRecognitionEngine(culture);
         recEngine.LoadGrammarAsync(grammar);
         Console.WriteLine("Laddat enginen med " + lang);
     }
     catch (UnauthorizedAccessException e)
     {
         Console.WriteLine("Error: UnauthorizedAccessException");
         Console.WriteLine(e.ToString());
     } 
     init = true;
     recEngine.SetInputToDefaultAudioDevice();
     return recEngine;
 }
Ejemplo n.º 27
0
        public GrammarBuilder GetGrammar_Custom(string grammar)
        {
            Choices globalChoices = new Choices();
            string[] sentences = grammar.Split('|');
            foreach (string s in sentences)
            {
                GrammarBuilder sentenceBuilder = new GrammarBuilder();
                string[] words = s.Split(' ');
                foreach (string w in words)
                {
                    if (m_vocabulories.ContainsKey(w))
                        sentenceBuilder.Append(new Choices(m_vocabulories[w].ToArray()));
                    else if (w == "#Dictation")
                        sentenceBuilder.AppendDictation();
                    else if (w == "#WildCard")
                        sentenceBuilder.AppendWildcard();
                    else if (w != "")
                        sentenceBuilder.Append(w);
                }
                globalChoices.Add(sentenceBuilder);
            }

            GrammarBuilder globalBuilder = new GrammarBuilder(globalChoices);
            globalBuilder.Culture = m_culture;
            Console.WriteLine(globalBuilder.DebugShowPhrases);
            return globalBuilder;
        }
Ejemplo n.º 28
0
 public void LoadChoices(params VoiceCommand[] commands)
 {
     var choices = new Choices();
     foreach (var command in commands)
     {
         if (command.Semantics == null || command.Semantics.Length == 0)
             choices.Add(new SemanticResultValue(command.Word, command.Word));
         else
         {
             foreach (var sem in command.Semantics)
                 choices.Add(new SemanticResultValue(sem, command.Word));
         }
     }
     var gb = new GrammarBuilder { Culture = engine.RecognizerInfo.Culture };
     gb.Append(choices);
     engine.LoadGrammar(new Grammar(gb));
 }
Ejemplo n.º 29
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Choices commands = new Choices();

            commands.Add(new String[] { "Hello computer", "My day was fine. How are you?", "speak what I wrote" });

            GrammarBuilder gbuilder = new GrammarBuilder();

            gbuilder.Append(commands);
            Grammar grammar = new Grammar(gbuilder);

            //Load this grammar to recEngine
            recEngine.LoadGrammarAsync(grammar);
            recEngine.SetInputToDefaultAudioDevice();
            recEngine.SpeechRecognized += recEngine_SpeechRecognized;
        }
Ejemplo n.º 30
0
        private void Form1_Load(object sender, EventArgs e)
        {
            loadContacts();
            loadCities();
            Choices commands = new Choices();

            commands.Add(new String[] { "stop navigation",
                                        "turn bluetooth on", "turn bluetooth off", "play some music", "stop music",
                                        "end call", "cooling off", "cooling on" });
            GrammarBuilder builder = new GrammarBuilder(commands);
            Grammar        grammar = new Grammar(builder);

            engine.LoadGrammarAsync(grammar);
            engine.SetInputToDefaultAudioDevice();
            engine.SpeechRecognized += engine_SpeechRecognized;
        }
Ejemplo n.º 31
0
        private void Listen()
        {
            Choices colors = new Choices();

            colors.Add(new string[] { "red", "yellow", "green", "exit" });

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            Grammar g = new Grammar(gb);

            recognizer.LoadGrammar(g);

            recognizer.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(sre_SpeechRecognized);
        }
        private void loadGrammarAndCommands()
        {
            try
            {
                Choices  texts = new Choices();
                string[] lines = File.ReadAllLines(Environment.CurrentDirectory + "\\mediaplayercl.txt");

                texts.Add(lines);
                Grammar wordsList = new Grammar(new GrammarBuilder(texts));
                speechRecognitionEngine.LoadGrammar(wordsList);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void loadGrammarAndCommands()
 {
     try
     {
         Choices  texts = new Choices();
         string[] lines = File.ReadAllLines(Environment.CurrentDirectory + "\\textreader.txt");
         // add the text to the known choices of speechengine
         texts.Add(lines);
         Grammar wordsList = new Grammar(new GrammarBuilder(texts));
         speechRecognitionEngine.LoadGrammar(wordsList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 34
0
        static MiscCommands()
        {
            commands = JsonConvert.DeserializeObject <Dictionary <String, String> >(System.IO.File.ReadAllText("config/MiscCommands.json"));

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append("command");
            Choices choices = new Choices();

            foreach (String key in commands.Keys)
            {
                choices.Add(key);
            }
            gb.Append(choices);
            Instance = new MiscCommands(gb);
        }
Ejemplo n.º 35
0
        private void LoadGrammarAndCommands()
        {
            try
            {
                Choices  texts = new Choices();
                string[] lines = File.ReadAllLines(Environment.CurrentDirectory + "\\WeatherCommands.txt");

                texts.Add(lines);
                Grammar wordslist = new Grammar(new GrammarBuilder(texts));
                speechRecognition.LoadGrammar(wordslist);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 36
0
        public void escuchar()
        {
            string selectdoc = "select nom_pro from pro01";

            rec.SetInputToDefaultAudioDevice();
            Choices listadocente = new Choices();

            listadocente.Add(nuevoescucha.gramaticadocente(selectdoc));
            Grammar gramatica = new Grammar(new GrammarBuilder(listadocente));

            //Grammar gramatica = ;
            rec.LoadGrammar(gramatica);
            //rec.LoadGrammar(new DictationGrammar());
            rec.SpeechRecognized += _Recognition_SpeechRecognized;
            rec.RecognizeAsync(RecognizeMode.Multiple);
        }
Ejemplo n.º 37
0
        public void AddSettingsGrammar()
        {
            CurrentSettings = Loader.LoadSettings();
            var gb           = new GrammarBuilder(new Choices(new string[] { CurrentSettings.EnableKeyword, CurrentSettings.DisableKeyword }));
            var scopeChoices = new Choices();

            foreach (var item in CurrentSettings.Scopes)
            {
                var scopeGb        = new GrammarBuilder(item.Key);
                var optionsChoices = new Choices(item.Value.Options);
                scopeGb.Append(optionsChoices);
                scopeChoices.Add(scopeGb);
            }
            gb.Append(scopeChoices);
            Engine.LoadGrammar(new Grammar(gb));
        }
Ejemplo n.º 38
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Choices commands = new Choices();

            commands.Add(new string[] { "say hello", "print my name" }); // добавляем команды

            GrammarBuilder gBuilder = new GrammarBuilder();

            gBuilder.Append(commands);                // добавляем команды в словарь

            Grammar grammar = new Grammar(gBuilder);  // создаем словарь

            recEngine.LoadGrammarAsync(grammar);      // загружаем словарь
            recEngine.SetInputToDefaultAudioDevice(); // указывем микрофон
            recEngine.SpeechRecognized += recEngine_SpeachSpeechRecognized;
        }
Ejemplo n.º 39
0
    public static GrammarBuilder enableProfile(List <String> profileNames)
    {
        GrammarBuilder gb = new GrammarBuilder();

        Choices profileChoices = new Choices();

        SemanticResultValue semval = new SemanticResultValue("semval_ENABLEPROFILE", "Enable Profile");

        gb.Append(new SemanticResultKey("semkey_METACONTROLNAME", semval));
        foreach (String profile in profileNames)
        {
            profileChoices.Add(new SemanticResultValue("semval_" + profile.ToUpper(), profile));
        }
        gb.Append(new SemanticResultKey("semkey_PARAMETER1", profileChoices));
        //////////////////NOT DONE YET
    }
Ejemplo n.º 40
0
        public Grammar Launcher()
        {
            Choices AppName = new Choices();

            string[] apps = (string[])App.ToArray(typeof(string));
            AppName.Add(apps);
            GrammarBuilder gb_result = new GrammarBuilder();

            gb_result.Append(AppName);
            gb_result.Append("を開いて");
            Grammar g_result = new Grammar(gb_result);

            //Grammarに名前をつけてあげよねそうしよね
            g_result.Name = "application";
            return(g_result);
        }
Ejemplo n.º 41
0
        private void EpsilonWindow_Load(object sender, EventArgs e)
        {
            Choices commands = new Choices();

            commands.Add(gw.myGrammar());
            GrammarBuilder   gb = new GrammarBuilder();
            DictationGrammar dg = new DictationGrammar();

            gb.Append(commands, 1, 5);
            Grammar gram = new Grammar(gb);

            sre.LoadGrammarAsync(gram);
            sre.LoadGrammarAsync(dg);
            sre.SetInputToDefaultAudioDevice();
            sre.SpeechRecognized += sre_SpeechRecognized;
        }
Ejemplo n.º 42
0
        //-----------------------------------------------------------------------------------------------
        //-----------------------------------------------------------------------------------------------
        #region Private Methods
        private GrammarBuilder ConstructGrammarBuilder(string szStorageKey, params KeyValue[] aGrammers)
        {
            Choices choice = new Choices();

            foreach (KeyValue keyValue in aGrammers)
            {
                GrammarBuilder      grammarBuilder = new GrammarBuilder(keyValue.Key);
                SemanticResultValue rsltValue      = new SemanticResultValue(grammarBuilder, keyValue.Value);

                choice.Add(rsltValue.ToGrammarBuilder());
            }

            SemanticResultKey rsltKey = new SemanticResultKey(szStorageKey, choice.ToGrammarBuilder());

            return(rsltKey.ToGrammarBuilder());
        }
Ejemplo n.º 43
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            Choices theChoices = new Choices();

            theChoices.Add("Bielefeld");
            theChoices.Add("Gütersloh");
            theChoices.Add("Minden");
            theChoices.Add("Neuss");
            theChoices.Add("Düsseldorf");
            theChoices.Add("Köln");
            theChoices.Add("Christian");
            theChoices.Add("Irina");
            SpeechRecognizer recognizer = new SpeechRecognizer();

            recognizer.LoadGrammar(new Grammar(new GrammarBuilder(theChoices)));
            recognizer.SpeechRecognized += speechRecognized;
            recognizer.Enabled           = true;
        }
Ejemplo n.º 44
0
 private void Form1_Load(object sender, EventArgs e)
 {
     //initializing objects
     Main_Engine      = new SpeechRecognitionEngine();
     email_rec_engine = new SpeechRecognitionEngine();
     //showing console in form application
     AllocConsole();
     //initializing the object of choices
     super_commands_choices     = new Choices();
     local_work_command_choices = new Choices();
     super_command_List         = get_instance.cm_List.get_command_list();
     send_email_data            = get_instance.cm_List.get_local_work_command_list();
     yutto_answers = get_instance.yuuto_answer_list.get_yuuto_answer_list();
     //adding all the grammer into to create a grammer for matching
     if (super_command_List.Count > 0)
     {
         foreach (string word in super_command_List)
         {
             super_commands_choices.Add(word.ToString());
         }
     }
     else
     {
         MessageBox.Show("please add some data into your command list!");
     }
     if (send_email_data.Count > 0)
     {
         foreach (string word in send_email_data)
         {
             local_work_command_choices.Add(word.ToString());
         }
     }
     else
     {
         MessageBox.Show("Please add some data into local work command list!");
     }
     //creating 1st speech engine
     // recEngine.RequestRecognizerUpdate();
     Main_Engine.LoadGrammarAsync(new Grammar(new GrammarBuilder(super_commands_choices)));
     Main_Engine.SetInputToDefaultAudioDevice();
     Main_Engine.RecognizeAsync(RecognizeMode.Multiple);
     Main_Engine.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(recEngine_SpeachRecognized);
     //creating 2nd speech engine
     // rec.RequestRecognizerUpdate();
     email_rec_engine.LoadGrammarAsync(new Grammar(new GrammarBuilder(local_work_command_choices)));
     email_rec_engine.SetInputToDefaultAudioDevice();
 }
Ejemplo n.º 45
0
        public void startGame()
        {
            Choices commands = new Choices();

            commands.Add(new string[] { "north", "up",
                                        "south", "down",
                                        "west", "left",
                                        "east", "right",
                                        "hello",
                                        "show route",
                                        "enable diagonal",
                                        "disable diagonal",
                                        "new game",
                                        "clean",
                                        "size",
                                        "north east",
                                        "north west",
                                        "south east",
                                        "south west",
                                        "five", "six", "seven", "eight", "nine", "ten",
                                        "eleven", "twelve", "thirteen", "fourteen", "fifteen",
                                        "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "thirty", "forty", "fifty",
                                        "f**k you", "you suck", "new end", "new start", "help", "sebastian" });
            gBuilder = new GrammarBuilder();
            gBuilder.Append(commands);

            Grammar grammar = new Grammar(gBuilder);

            recEngine.LoadGrammarAsync(grammar);

            matriz = new Mapa(m, n, size);
            Random rnd   = new Random();
            int    tempM = rnd.Next(0, m - 1);
            int    tempN = rnd.Next(0, n - 1);

            matriz.setElementoPos(tempM, tempN, 2);
            matriz.colocarInicio(tempM, tempN);


            int randX = rnd.Next(0, m - 1);

            int randY = rnd.Next(0, n - 1);

            matriz.setElementoPos(randX, randY, 4);
            matriz.colocarFinal(randX, randY);
            matriz.colocarObstaculos((m * n) / 6);
        }
Ejemplo n.º 46
0
        static void Main(String[] args)
        {
            Console.WriteLine("Welcome!!!");
            SpeechRecognitionEngine sre = new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US"));

            string[] lines = new string[] {
                "copy",
                "cut",
                "delete",
                "find",
                "format",
                "go to line",
                "hello world",
                "paste",
                "quick open",
                "redo",
                "search",
                "select all",
                "stop listen",
                "undo",
                "write return size",
                "write return zero",
                "add marvel character",
                "var count equals zero",
                "write for loop",
                "change size to n"
            };
            Choices words = new Choices();

            words.Add(lines);

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(words);

            // Create the Grammar instance.
            Grammar g = new Grammar(gb);

            sre.LoadGrammar(g);
            sre.SetInputToDefaultAudioDevice();
            sre.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(sre_SpeechRecognized);

            while (true)
            {
                sre.Recognize();
            }
        }
Ejemplo n.º 47
0
        private void speakToAndFromProgram()
        {
            if (hasAddedLetters == false)
            {
                addLetters();
                addExtraCommands();
                addWords();
                hasAddedLetters = true;
            }


            Choices commands = new Choices();

            commands.Add(commandList.ToArray());
            //testCounter += 1;
            GrammarBuilder gBuilder = new GrammarBuilder();

            gBuilder.Append(commands);
            Grammar grammar = new Grammar(gBuilder);

            recEngine.LoadGrammarAsync(grammar);
            recEngine.SetInputToDefaultAudioDevice();
            recEngine.SpeechRecognized += recEngine_SpeechRecognized;

            /*
             * Choices commands = new Choices();
             * //commandList = new string[26];
             *
             * //loadedCommands.CopyTo(commandList, 0);
             * cooldownTimer += 10;
             * commands.Add(commandList.ToArray());
             * GrammarBuilder gBuilder = new GrammarBuilder();
             * gBuilder.Append(commands);
             * Grammar grammar = new Grammar(gBuilder);
             *
             * recEngine.LoadGrammarAsync(grammar);
             * recEngine.LoadGrammar(new DictationGrammar());
             *
             *
             * recEngine.SetInputToDefaultAudioDevice();
             * //recEngine.SpeechDetected += recEngine_SpeechDetected;
             *
             * //recEngine.SpeechRecognitionRejected += recEngine_SpeechRecognitionRejected;
             * recEngine.SpeechRecognized += recEngine_SpeechRecognized;
             *
             */
        }
Ejemplo n.º 48
0
        static void Main(string[] args)
        {
            var ci        = new CultureInfo("en-us");
            var ciRussian = new CultureInfo("ru-RU");

            commands       = new List <string>();
            currentCommand = string.Empty;
            promptBuilder  = new PromptBuilder();

            synthesizer = new SpeechSynthesizer();
            voices      = synthesizer.GetInstalledVoices();
            foreach (var voice in voices)
            {
                Console.WriteLine(voice.VoiceInfo.Name);
                Console.WriteLine(voice.VoiceInfo.Description);
                Console.WriteLine(voice.VoiceInfo.Age);
            }
            speechRecognitionEngine = new SpeechRecognitionEngine(ci);
            speechRecognitionEngine.SetInputToDefaultAudioDevice();
            speechRecognitionEngine.SpeechRecognized += Sre_SpeechRecognized;

            var choices = new Choices();

            choices.Add(new string[] { "say hello", "how are you", "print my name", "open notepad", "show my mail", "speak selected text", "shutdown" });
            //choices.Add(new string[] { "привет", "как дела", "взял и потащил", "раз", "два", "три", "четыре", "пять" });

            var gb = new GrammarBuilder();

            gb.Append(choices);
            gb.Culture = ci;

            var grammar = new Grammar(gb);

            speechRecognitionEngine.LoadGrammar(grammar);
            //var dictationGrammar = new DictationGrammar();
            //sre.LoadGrammar(dictationGrammar);

            speechRecognitionEngine.RecognizeAsync(RecognizeMode.Multiple);

            while (true)
            {
                Console.WriteLine("Input text to be spoken by machine:");
                currentCommand = Console.ReadLine();
                Console.WriteLine($"Text to be spoken by machine: {currentCommand}");
            }
            Console.ReadLine();
        }
Ejemplo n.º 49
0
        public void Withdrawal(int accountNo)
        {
            try
            {
                this.accountNo = accountNo;
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "Select AccountBalance From AccountDetails where AccountNo = '" + accountNo + "'";
                dr = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        accountBal = dr.GetInt32(0);
                        Console.WriteLine("Account Balance is : " + accountBal);
                    }
                }
                conn.Close();


                speechSynthesizer.SpeakAsync("To withdraw money. Say like Withdraw and your amount how much you want to withdraw. Example if You want to withdraw 500 rupees then say Withdraw 500.");
                speechSynthesizer.SpeakAsync("Hello . Now tell me How much amount you want to withdraw?");
                speechrecEngine4 = new SpeechRecognitionEngine();
                Choices chList2 = new Choices();
                chList2.Add(new string[] { "Withdraw 100", "Withdraw 200", "Withdraw 300", "Withdraw 400", "Withdraw 500", "Withdraw 600", "Withdraw 700", "Withdraw 800", "Withdraw 900", "Withdraw 1000",
                                           "Withdraw 1100", "Withdraw 1200", "Withdraw 1300", "Withdraw 1400", "Withdraw 1500", "Withdraw 1600", "Withdraw 1700", "Withdraw 1800", "Withdraw 1900", "Withdraw 2000",
                                           "Withdraw 2100", "Withdraw 2200", "Withdraw 2300", "Withdraw 2400", "Withdraw 2500", "Withdraw 2600", "Withdraw 2700", "Withdraw 2800", "Withdraw 2900", "Withdraw 3000",
                                           "Withdraw 3100", "Withdraw 3200", "Withdraw 3300", "Withdraw 3400", "Withdraw 3500", "Withdraw 3600", "Withdraw 3700", "Withdraw 3800", "Withdraw 3900", "Withdraw 4000",
                                           "Withdraw 4100", "Withdraw 4200", "Withdraw 4300", "Withdraw 4400", "Withdraw 4500", "Withdraw 4600", "Withdraw 4700", "Withdraw 4800", "Withdraw 4900", "Withdraw 5000",
                                           "Withdraw 5100", "Withdraw 5200", "Withdraw 5300", "Withdraw 5400", "Withdraw 5500", "Withdraw 5600", "Withdraw 5700", "Withdraw 5800", "Withdraw 5900", "Withdraw 6000",
                                           "Withdraw 6100", "Withdraw 6200", "Withdraw 6300", "Withdraw 6400", "Withdraw 6500", "Withdraw 6600", "Withdraw 6700", "Withdraw 6800", "Withdraw 6900", "Withdraw 7000",
                                           "Withdraw 7100", "Withdraw 7200", "Withdraw 7300", "Withdraw 7400", "Withdraw 7500", "Withdraw 7600", "Withdraw 7700", "Withdraw 7800", "Withdraw 7900", "Withdraw 8000",
                                           "Withdraw 8100", "Withdraw 8200", "Withdraw 8300", "Withdraw 8400", "Withdraw 8500", "Withdraw 8600", "Withdraw 8700", "Withdraw 8800", "Withdraw 8900", "Withdraw 9000",
                                           "Withdraw 9100", "Withdraw 9200", "Withdraw 9300", "Withdraw 9400", "Withdraw 9500", "Withdraw 9600", "Withdraw 9700", "Withdraw 9800", "Withdraw 9900", "Withdraw 10000", "Cancel" });
                Grammar grammer2 = new Grammar(new GrammarBuilder(chList2));
                //speechrecEngine4.RequestRecognizerUpdate();
                speechrecEngine4.LoadGrammar(grammer2);
                speechrecEngine4.SpeechRecognized += SpeechrecEngine4_SpeechRecognized;
                speechrecEngine4.SetInputToDefaultAudioDevice();
                speechrecEngine4.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.Message);
            }
        }
        //dodanie nazw piosenek do gramatyki systemu rozpoznawania, zczytujac nazwy piosenek z pliku, ktory najpierw zostaje stworzony
        private void addSongNamesTotheDictionary(Choices choices_, string LINK)
        {
            Process getSongNamesProcess = new Process();
            Process clearFile           = new Process();

            try
            {
                clearFile.StartInfo.FileName  = "cmd.exe";
                clearFile.StartInfo.Arguments = "/c TYPE nul > " + filePath;
                clearFile.Start();

                getSongNamesProcess.StartInfo.FileName  = "cmd.exe";
                getSongNamesProcess.StartInfo.Arguments = "/c dir /b " + LINK + " >> songNames.txt";
                getSongNamesProcess.Start();
            }
            catch
            {
                MessageBox.Show("The file couldn't have been created");
            }

            WMPLib.IWMPControls3 controls = (WMPLib.IWMPControls3)wmplayer.Ctlcontrols;
            controls.play();

            WMPLib.IWMPPlaylist playlist = wmplayer.playlistCollection.newPlaylist("myplaylist");

            try
            {
                using (StreamReader sr = File.OpenText(filePath))
                {
                    string line = null;
                    while ((line = sr.ReadLine()) != null)
                    {
                        media = wmplayer.newMedia(LINK + @"\" + line);
                        line  = line.Substring(0, line.Length - 4);
                        listBox1.Items.Add(line);
                        playlist.appendItem(media);
                        choices_.Add("Katherine play " + line);
                    }
                    wmplayer.currentPlaylist = playlist;
                    wmplayer.Ctlcontrols.stop();
                }
            }
            catch
            {
                MessageBox.Show("STREAMREADER FAILED ;___;");
            }
        }
Ejemplo n.º 51
0
        public void configureAudio(KinectSensor nui)
        {
            //on configure la source de l'audio
            _source = nui.AudioSource;
            _source.EchoCancellationMode        = EchoCancellationMode.CancellationOnly;
            _source.AutomaticGainControlEnabled = false;
            _source.BeamAngleMode = BeamAngleMode.Adaptive;

            //on récupère le dictionnaire de la langue choisi
            RecognizerInfo ri = SpeechRecognitionEngine.InstalledRecognizers().Where(r => r.Id == RecognizerId).FirstOrDefault();

            if (ri == null)
            {
                _remoteOperation.message("Impossible de trouver le fichier de langue: reconnaissance vocale désactivée");
                return;
            }

            _remoteOperation.message("Configuration de la reconnaissance vocale....");

            _sre = new SpeechRecognitionEngine(ri.Id);

            //on charge les mots de profils et ajoute le verrouillage de la voix
            Choices words = new Choices();

            _profileWords.Add("Lock my voice.", null);
            _profileWords.Add("Unlock my voice.", null);
            foreach (String s in _profileWords.Keys)
            {
                words.Add(s);
            }

            //on contruit la grammaire autour de ces mots
            GrammarBuilder gb = new GrammarBuilder {
                Culture = ri.Culture
            };

            _culture = ri.Culture;
            gb.Append(words);

            // Create the actual Grammar instance, and then load it into the speech recognizer.
            Grammar g = new Grammar(gb);

            _sre.LoadGrammar(g);
            Thread.Sleep(1000);
            //on s'abonne à la reconnaissance des mots
            _sre.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(SreSpeechRecognized);
        }
Ejemplo n.º 52
0
        public static void Initialize()
        {
            try
            {
                ss.SetOutputToDefaultAudioDevice(); // Creo que esto no se usa nunca
                CultureInfo ci = new CultureInfo("es-ES"); // Para que el idioma de la entrada de voz sea espaniol

                //Comandos
                sreComandos = new SpeechRecognitionEngine(ci);
                sreComandos.SetInputToDefaultAudioDevice();

                //Teclado <-- NO LO TERMINE YET
                //sreTeclado = new SpeechRecognitionEngine(ci);
                //sreTeclado.SetInputToDefaultAudioDevice();
                //dictation = new DictationGrammar();
                //dictation.Name = "default dictation";
                //dictation.Enabled = true;
                //sreTeclado.LoadGrammar(dictation);
                //sreTeclado.SpeechRecognized += sreTeclado_SpeechRecognized;
                //sreTeclado.RecognizeAsync(RecognizeMode.Multiple);

                Choices choices = new Choices(); // Opciones para decir
                choices.Add("click");
                choices.Add("doble click");
                choices.Add("click derecho");
                choices.Add("seleccionar");
                choices.Add("desseleccionar");
                choices.Add("desconectar");
                choices.Add("silencio");
                choices.Add("activar teclado"); 

                sreComandos.SpeechRecognized += sreComandos_SpeechRecognized; //Cuando reconoce alguna de las opciones, va a la funcion
                GrammarBuilder grammarBuilder = new GrammarBuilder();
                grammarBuilder.Append(choices);
                Grammar grammar = new Grammar(grammarBuilder);
                sreComandos.LoadGrammar(grammar);
                sreComandos.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        } // Main
Ejemplo n.º 53
0
        public void bfehjvfusdvlsabcuvsdfilvsdkz()
        {
            Choices colors = new Choices();

            colors.Add(new string[] { "red", "green", "blue" });

            GrammarBuilder gb = new GrammarBuilder();

            gb.Append(colors);

            // Create the Grammar instance.
            Grammar g = new Grammar(gb);

            //sre.SetInputToWaveFile(@"c:\Test\Colors.wav");
            sre.SetInputToDefaultAudioDevice();
            sre.LoadGrammar(g);
        }
Ejemplo n.º 54
0
        public bool Initialise(string[] commands)
        {
            Choices choices = new Choices();

            choices.Add(commands);
            GrammarBuilder gramBuilder = new GrammarBuilder();

            gramBuilder.Append(choices);
            Grammar grammer = new Grammar(gramBuilder);

            SpeechRecEngine.LoadGrammarAsync(grammer);
            SpeechRecEngine.SetInputToDefaultAudioDevice();

            SpeechRecEngine.SpeechRecognized += SpeechRecEngine_SpeechRecognized;

            return(true);
        }
Ejemplo n.º 55
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Choices command = new Choices();

            //command.Add(new string[] { "Hello","print my name","Open Chrome","Play Songs","Open Notepad","Close Notepad","Current Time", "Lock My Computer","Mark All","Copy","Paste","Looking For", "play","pause", "Close Chrome" });

            command.Add(File.ReadAllLines(@"F:/voice command/command.txt"));
            GrammarBuilder gbuilder = new GrammarBuilder();

            gbuilder.Append(command);
            Grammar grammar = new Grammar(gbuilder);

            rec.LoadGrammarAsync(grammar);
            rec.SetInputToDefaultAudioDevice();

            rec.SpeechRecognized += rec_speechRecognized;
        }
Ejemplo n.º 56
0
/// <summary>
/// Metoda LoadGrammar
/// </summary>
        private void LoadGrammarAndCommands()
        {
            try
            {
                Choices Text = new Choices();                                                        ///Rozkazy z Commands.txt są ładowane do grammar

                string[] Lines = File.ReadAllLines(Environment.CurrentDirectory + "\\Commands.txt"); ///Zczytywanie rozkazów z Commands.txt
                Text.Add(Lines);

                Grammar WordList = new Grammar(new GrammarBuilder(Text));///Pobieranie i ładowanie rozkazów do silnika
                speechRecognitionEngine.LoadGrammar(WordList);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 57
0
        private void Form4_Load(object sender, EventArgs e)
        {
            Choices commands = new Choices();

            for (int i = 0; i < preposition.Length - 1; i++)
            {
                commands.Add(preposition[i]);
            }
            GrammarBuilder gBuilder = new GrammarBuilder();

            gBuilder.Append(commands);
            Grammar grammar = new Grammar(gBuilder);

            recEngine.LoadGrammarAsync(grammar);
            recEngine.SetInputToDefaultAudioDevice();
            recEngine.SpeechRecognized += recEngine_SpeechRecognized;
        }
        private void voiceCommand_Load(object sender, EventArgs e)
        {
            Choices command = new Choices();

            command.Add(new string[] { "open notepad", "open word", "open calculator", "open excel"
                                       , "open snipping", "open google", "open youtube", "open notepad plus plus"
                                       , "open paint", "open powerpoint", "edit photo", "send mail"
                                       , "set alarm", "song", "check net" });
            GrammarBuilder gBuilder = new GrammarBuilder();

            gBuilder.Append(command);
            Grammar grammar = new Grammar(gBuilder);

            recEngine.LoadGrammarAsync(grammar);
            recEngine.SetInputToDefaultAudioDevice();
            recEngine.SpeechRecognized += recEngine_SpeechRecognized;
        }
Ejemplo n.º 59
-1
        public Form1()
        {
            SpeechRecognitionEngine rec = new SpeechRecognitionEngine();
            Choices list = new Choices();

            list.Add(new String[] { "hello", "how are you" , "i'm fine" });

            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("Hello , My name is VoiceBot");

            InitializeComponent();
        }
Ejemplo n.º 60
-1
        public void button1_Click(object sender, EventArgs e)
        {
            button1.Enabled = false;
            button1.Text = "God Called";
            label2.Text = "The god is listening...";
            label2.ForeColor = Color.Red;

            SpeechRecognitionEngine GodListener = new SpeechRecognitionEngine();

            Choices GodList = new Choices();
            GodList.Add(new string[] { "Make toast", "Make me toast", "Make me some toast", "Make me immortal", "Make rain", "call rain", "call the rain", "make it rain", "wink out of existence", "begone", "go now", "wink yourself out of existence" });

            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(GodList);

            Grammar GodGrammar = new Grammar(gb);

            GodListener.MaxAlternates = 2;

            try
            {
                GodListener.RequestRecognizerUpdate();
                GodListener.LoadGrammar(GodGrammar);
                GodListener.SetInputToDefaultAudioDevice();
                GodListener.SpeechRecognized += GodListener_SpeechRecognized;
                GodListener.AudioStateChanged += GodListener_AudioStateChanged;
                GodListener.AudioLevelUpdated += GodListener_AudioLevelUpdated;
                GodListener.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch
            {
                return;
            }
        }