private void btnRecognize_Click(object sender, RoutedEventArgs e) { text = txtInput.Text.ToLower(); text = CleanText(text); words = text.Split(' '); wcount = words.Length; //words = words.Distinct().ToArray(); txtOutput.Text = text; Choices choices = new Choices(words); GrammarBuilder gb = new GrammarBuilder(new GrammarBuilder(choices), 0, wcount); //GrammarBuilder gb = new GrammarBuilder(txtInput.Text.Trim()); gb.Culture = new CultureInfo("es-MX"); Grammar grammar = new Grammar(gb); //recognizer = new SpeechRecognitionEngine("SR_MS_es-MX_TELE_11.0"); //recognizer = new SpeechRecognitionEngine(new CultureInfo("es-MX")); recognizer.LoadGrammar(grammar); recognizer.SetInputToWaveFile(@"E:\Proyectos\Audio Timestamps\chapter01.wav"); //recognizer.SetInputToDefaultAudioDevice(); recognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(RecognizeCompletedHandler); recognizer.RecognizeAsync(RecognizeMode.Multiple); }
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); }
public VoiceSelect() { precision = .5; newWordReady = false; RecognizerInfo ri = GetKinectRecognizer(); SpeechRecognitionEngine tempSpeechRec; tempSpeechRec = new SpeechRecognitionEngine(ri.Id); var grammar = new Choices(); grammar.Add("select one", "SELECT ONE", "Select One"); grammar.Add("select two", "SELECT TWO", "Select Two"); grammar.Add("pause", "PAUSE"); grammar.Add("exit", "EXIT"); grammar.Add("single player", "SINGLE PLAYER"); grammar.Add("co op mode", "CO OP MODE"); grammar.Add("settings", "SETTINGS"); grammar.Add("instructions", "INSTRUCTIONS"); grammar.Add("statistics", "STATISTICS"); grammar.Add("Main Menu", "MAIN MENU"); grammar.Add("resume", "RESUME"); grammar.Add("restart level", "RESTART LEVEL"); grammar.Add("replay", "REPLAY"); grammar.Add("next", "NEXT"); grammar.Add("Easy", "EASY"); grammar.Add("Hard", "HARD"); /* grammar.Add("level one"); grammar.Add("level two"); grammar.Add("level three"); grammar.Add("level four"); grammar.Add("level five"); grammar.Add("level six"); grammar.Add("player one left"); grammar.Add("player one right"); grammar.Add("player two left"); grammar.Add("player two right"); grammar.Add("room low"); grammar.Add("room medium"); grammar.Add("room high"); grammar.Add("sounds on"); grammar.Add("sounds off"); grammar.Add("reset stats"); */ var gb = new GrammarBuilder { Culture = ri.Culture }; gb.Append(grammar); // Create the actual Grammar instance, and then load it into the speech recognizer. var g = new Grammar(gb); tempSpeechRec.LoadGrammar(g); tempSpeechRec.SpeechRecognized += phraseRecognized; tempSpeechRec.SpeechHypothesized += phraseHyphothesized; tempSpeechRec.SpeechRecognitionRejected += phraseRejected; speechRec = tempSpeechRec; }
//here is the fun part: create the speech recognizer private SpeechRecognitionEngine CreateSpeechRecognizer() { //set recognizer info RecognizerInfo ri = GetKinectRecognizer(); //create instance of SRE SpeechRecognitionEngine sre; sre = new SpeechRecognitionEngine(ri.Id); //Now we need to add the words we want our program to recognise var grammar = new Choices(); grammar.Add("Record"); grammar.Add("Store"); grammar.Add("Replay"); grammar.Add("Stop"); grammar.Add("Learn"); grammar.Add("Finish"); //set culture - language, country/region var gb = new GrammarBuilder { Culture = ri.Culture }; gb.Append(grammar); //set up the grammar builder var g = new Grammar(gb); sre.LoadGrammar(g); //Set events for recognizing, hypothesising and rejecting speech sre.SpeechRecognized += SreSpeechRecognized; sre.SpeechHypothesized += SreSpeechHypothesized; sre.SpeechRecognitionRejected += SreSpeechRecognitionRejected; return sre; }
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; }
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)); }
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(); }
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)); }
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); }
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(); } }
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); } }
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); }
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); }
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; }
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(); }
public void CreateAndLoadGrammarWithObjectsNames(string[] objNames) { // przesuwanie obiektow z wykorzystaniem nazw Choices objWithNames = new Choices(objNames); GrammarBuilder gbMOWN = new GrammarBuilder { Culture = recognizerInfo.Culture }; gbMOWN.Append("move"); gbMOWN.Append(new SemanticResultKey("OWN_MOVE_NAME", objWithNames)); Grammar gMOWN = new Grammar(gbMOWN); // tworzenie obiektow z wykorzystaniem nazw, bez podawania kierunku GrammarBuilder gbCOWN = new GrammarBuilder { Culture = recognizerInfo.Culture }; gbCOWN.Append("new"); gbCOWN.Append(new SemanticResultKey("OWN_NEW_NAME", objWithNames)); Grammar gCOWN = new Grammar(gbCOWN); // usuwanie obiektow z wykorzystaniem nazw GrammarBuilder gbROWN = new GrammarBuilder { Culture = recognizerInfo.Culture }; gbROWN.Append("remove"); gbROWN.Append(new SemanticResultKey("OWN_REMOVE_NAME", objWithNames)); Grammar gROWN = new Grammar(gbROWN); // ladujemy wszystkie gramatyki speechEngine.LoadGrammar(gMOWN); speechEngine.LoadGrammar(gCOWN); speechEngine.LoadGrammar(gROWN); mainEngine.AddTextToLog("SpeechRec: " + "grammars loaded"); }
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; }
private Choices getCommands() { var commands = new Choices(); commands.Add(new SemanticResultValue("left", "left")); commands.Add(new SemanticResultValue("previous", "left")); commands.Add(new SemanticResultValue("right", "right")); commands.Add(new SemanticResultValue("next", "right")); commands.Add(new SemanticResultValue("enter", "enter")); commands.Add(new SemanticResultValue("accept", "enter")); commands.Add(new SemanticResultValue("ok", "enter")); commands.Add(new SemanticResultValue("go", "enter")); commands.Add(new SemanticResultValue("confirm", "enter")); commands.Add(new SemanticResultValue("quit", "exit")); commands.Add(new SemanticResultValue("exit", "exit")); commands.Add(new SemanticResultValue("back", "exit")); commands.Add(new SemanticResultValue("cancel", "exit")); commands.Add(new SemanticResultValue("return", "exit")); commands.Add(new SemanticResultValue("tv", "input")); commands.Add(new SemanticResultValue("television", "input")); commands.Add(new SemanticResultValue("up", "up")); commands.Add(new SemanticResultValue("more", "up")); commands.Add(new SemanticResultValue("higher", "up")); commands.Add(new SemanticResultValue("down", "down")); commands.Add(new SemanticResultValue("less", "down")); commands.Add(new SemanticResultValue("lower", "down")); return commands; }
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(); }
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; }
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; }
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; }
private Grammar ColorFilterGrammar() { // Add/Set Filter Choices GrammarBuilder addGrammar = "Add"; GrammarBuilder setGrammar = "Set"; GrammarBuilder filterGrammar = "Filter"; Choices colorChoice = new Choices(); foreach (string colorName in System.Enum.GetNames(typeof(KnownColor))) { SemanticResultValue choiceResultValue = new SemanticResultValue(colorName, Color.FromName(colorName).ToArgb()); GrammarBuilder resultValueBuilder = new GrammarBuilder(choiceResultValue); colorChoice.Add(resultValueBuilder); } SemanticResultKey resultKey = new SemanticResultKey("colorFilter", colorChoice); GrammarBuilder resultContrast = new GrammarBuilder(resultKey); Choices alternatives = new Choices(addGrammar, setGrammar); GrammarBuilder result = new GrammarBuilder(alternatives); result.Append(filterGrammar); result.Append(resultContrast); Grammar grammar = new Grammar(result); grammar.Name = "Set Contrast"; return grammar; }
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; }
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(); } }
//Speech recognizer private SpeechRecognitionEngine CreateSpeechRecognizer() { RecognizerInfo ri = GetKinectRecognizer(); SpeechRecognitionEngine sre; sre = new SpeechRecognitionEngine(ri.Id); //words we need the program to recognise var grammar = new Choices(); grammar.Add(new SemanticResultValue("moustache", "MOUSTACHE")); grammar.Add(new SemanticResultValue("top hat", "TOP HAT")); grammar.Add(new SemanticResultValue("glasses", "GLASSES")); grammar.Add(new SemanticResultValue("sunglasses", "SUNGLASSES")); grammar.Add(new SemanticResultValue("tie", "TIE")); grammar.Add(new SemanticResultValue("bow", "BOW")); grammar.Add(new SemanticResultValue("bear", "BEAR")); //etc var gb = new GrammarBuilder { Culture = ri.Culture }; gb.Append(grammar); var g = new Grammar(gb); sre.LoadGrammar(g); //Events for recognising and rejecting speech sre.SpeechRecognized += SreSpeechRecognized; sre.SpeechRecognitionRejected += SreSpeechRecognitionRejected; return sre; }
/* * 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; }
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; }
public static void Initialise(Window Display) { AnimaCentral.SpeechEngine = new SpeechRecognitionEngine(System.Globalization.CultureInfo.CurrentCulture); AnimaCentral._displayWindow = Display; AnimaCentral.Voice = new SpeechSynthesizer(); AnimaCentral.Voice.SetOutputToDefaultAudioDevice(); if (Properties.CoreSettings.Default.Voice == String.Empty) { Properties.CoreSettings.Default.Voice = AnimaCentral.Voice.Voice.Name; Properties.CoreSettings.Default.Save(); } else { AnimaCentral.Voice.SelectVoice(Properties.CoreSettings.Default.Voice); } AnimaCentral.Image = new BitmapImage(new Uri(DefaultImageResource, UriKind.RelativeOrAbsolute)); AnimaCentral.SpeechQueue = new Queue <Prompt>(); AnimaCentral.Pos = new Position(0, 0); AnimaCentral.Commands = new List <Command>(); AnimaCentral.PlugMan = new PluginManager(); ShuttingDown = false; var NumberChoices = new Choices(); for (int i = 0; i <= 100; i++) { NumberChoices.Add(i.ToString()); } Numbers = NumberChoices; InitialiseSpeech(); }
//When player enters a room public static Player CurrentRoom(Player player, Room room) { var temp_player = (Player)player.Clone(); room.GetRoomStats(); if (room.Enemy != null && room.Enemy.Health > 0) { Battle.Battleground(temp_player, room.Enemy); if (temp_player.Health > 0) { Console.WriteLine("Enemy has fallen"); } Text.Continue(); } else { Console.WriteLine("Room seems to be empty..."); } Stats.ResetStats(player, temp_player); if (room.HasItem()) { Stats.AddNewItemFromRoom(player, room); } if (room.Stars != 0) { player.SecretMessage.CollectStar(room.Stars); } if (!player.SecretMessage.CollectedAllStars()) { player.NextRoom = Choices.ChooseDoor(room); room.Stars = 0; } return(player); }
private void Load_Grammer_With_Substitutions() { List <string> objectList = new List <string>(); DataSet dsResults = new DataSet(); try { //Load all unique patterns with no place-holders into a single grammer, our main one. dsResults = OSAESql.RunSQL("SELECT object_name FROM osae_object ORDER BY object_name"); for (int i = 0; i < dsResults.Tables[0].Rows.Count; i++) { string grammer = dsResults.Tables[0].Rows[i][0].ToString(); if (!string.IsNullOrEmpty(grammer)) { objectList.Add(grammer); } } } catch (Exception ex) { AddToLog("Error getting Object Set set from the DB!"); AddToLog("Error: " + ex.Message); } try { Choices myChoices = new Choices(objectList.ToArray()); // Construct the phrase. GrammarBuilder builder = new GrammarBuilder("Where is"); builder.Append(myChoices); Grammar gram = new Grammar(builder); oRecognizer.LoadGrammar(gram); AddToLog("Grammer Load Completed (" + objectList.Count + " items with place-holders)"); } catch (Exception ex) { AddToLog("I could Not build the Grammer set!"); AddToLog("Error: " + ex.Message); } }
public static void SetGrammar() { try { engine = new SpeechRecognitionEngine(new CultureInfo(ConfigurationManager.AppSettings["CULTURE_INFO"])); } catch (Exception ex) { Console.WriteLine($"Error to integrate the language. Error message {ex.Message}"); } var grammar = new Choices(); grammar.Add(wordsList); var gb = new GrammarBuilder(); gb.Append(grammar); try { var g = new Grammar(gb); try { engine.RequestRecognizerUpdate(); engine.LoadGrammarAsync(g); engine.SetInputToDefaultAudioDevice(); speechSender.SetOutputToDefaultAudioDevice(); engine.RecognizeAsync(RecognizeMode.Multiple); } catch (Exception ex) { Console.WriteLine($"Error to create the Engine. Error message {ex.Message}"); } } catch (Exception ex) { Console.WriteLine($"Error to create the Grammar. Error message {ex.Message}"); } }
private void Form1_Load(object sender, EventArgs e) { //create new tab at startup newcode(); GetRichTextBox().Focus(); //...........end // setting droping text file GetRichTextBox().AllowDrop = true; GetRichTextBox().DragDrop += new DragEventHandler(GetRichTextBox_DragDrop); toolLab.Text = "Ready"; //voice recognition seting voice = new SpeechSynthesizer(); Choices commands = new Choices(); commands.Add(new string[] { "new file", "undo", "redo", "delete that", "close application" }); GrammarBuilder gBuilder = new GrammarBuilder(); gBuilder.Append(commands); Grammar grammer = new Grammar(gBuilder); DictationGrammar dg = new DictationGrammar(); // recEngine.LoadGrammar(dg); // recEngine.RecognizeAsync(); recEngine.LoadGrammarAsync(grammer); recEngine.SetInputToDefaultAudioDevice(); recEngine.SpeechRecognized += recEngine_SpeechRecognized; disableVoiceToolStripMenuItem.Enabled = false; //..............................text ................ GetRichTextBox().SelectionStart = GetRichTextBox().TextLength; GetRichTextBox().ScrollToCaret(); }
private void LoadGrammar(SpeechRecognitionEngine speechRecognitionEngine) { var InMode = new Choices(); foreach (var phrase in InModePhrases) { InMode.Add(phrase.Key); } var gb = new GrammarBuilder(); gb.Culture = speechRecognitionEngine.RecognizerInfo.Culture; gb.Append(InMode); var g = new Grammar(gb); speechRecognitionEngine.LoadGrammar(g); speechRecognitionEngine.SpeechRecognized += sre_SpeechRecognized; speechRecognitionEngine.SpeechHypothesized += sre_SpeechHypothesized; speechRecognitionEngine.SpeechRecognitionRejected += new EventHandler <SpeechRecognitionRejectedEventArgs>(sre_SpeechRecognitionRejected); }
/// <summary> /// Loads Speech Engine with the required Grammar. /// </summary> private void Initialize() { nameRecognizer = new SpeechRecognitionEngine(); Choices alphabets = new Choices(); string[] letters = new string[26]; int letterCounter = 0; for (char c = 'A'; c <= 'Z'; c++) { letters[letterCounter] = c.ToString(); letterCounter++; } alphabets.Add(letters); GrammarBuilder grammarBuilderForAddName = new GrammarBuilder(); grammarBuilderForAddName.Append(alphabets); Grammar grammarForAddName = new Grammar(grammarBuilderForAddName); nameRecognizer.LoadGrammarAsync(grammarForAddName); }
protected void Page_Load(object sender, EventArgs e) { // Create a new instance of the Tropo object. Tropo tropo = new Tropo(); // Say an introductory message to the caller. tropo.Say("Welcome to the claim test application."); // Create new choices to use with Ask. Choices choices = new Choices("[5 DIGITS]"); // Create new ask with desired prompt that will be sent to user. tropo.Ask(3, false, choices, null, "claim_id", true, new Say("Please enter your 5 digits claim ID."), 5); // Create On handlers for Tropo event. tropo.On(Event.Continue, "Answer.aspx", null); // Fires when the user provides valid input. tropo.On(Event.Error, "Error.aspx", null); // Fires when an error occurs. tropo.On(Event.Incomplete, "Error.aspx", null); // Fires when the user does not enter correct input. tropo.RenderJSON(Response); }
public Details() { InitializeComponent(); speechRecognizer.SpeechRecognized += speechRecognizer_SpeechRecognized; GrammarBuilder grammarBuilder = new GrammarBuilder(); Choices commandChoices = new Choices("weight", "color", "size"); grammarBuilder.Append(commandChoices); Choices valueChoices = new Choices(); valueChoices.Add("normal", "bold"); valueChoices.Add("red", "green", "blue"); valueChoices.Add("small", "medium", "large"); grammarBuilder.Append(valueChoices); speechRecognizer.LoadGrammar(new Grammar(grammarBuilder)); speechRecognizer.SetInputToDefaultAudioDevice(); }
private void UnloadGrammarAndCommands() { Choices texts = new Choices(); lines = File.ReadAllLines(Environment.CurrentDirectory + "\\citynamelist.txt"); // add the text to the known choices of speechengine texts.Add(lines); Grammar wordsList = new Grammar(new GrammarBuilder(texts)); speechRecognitionEngine.LoadGrammar(wordsList); try { Weathergrammar = new Grammar(new GrammarBuilder(new Choices(ArrayWeatherCommands))); speechRecognitionEngine.UnloadGrammar(Weathergrammar); } catch (Exception ex) { Marvel.SpeakAsync("I've detected an in valid entry in your weather commands, possibly a blank line. web commands will cease to work until it is fixed."); } }
private void buildCommands() { Choices commands = new Choices(); commands.Add("Red"); commands.Add("Green"); commands.Add("Blue"); commands.Add("Yellow"); commands.Add("Cyan"); commands.Add("Orange"); commands.Add("Purple"); GrammarBuilder grammarBuilder = new GrammarBuilder(); grammarBuilder.Culture = kinectRecognizerInfo.Culture; grammarBuilder.Append(commands); Grammar grammar = new Grammar(grammarBuilder); recognizer.LoadGrammar(grammar); }
public Grammar searchLyricsGrammar() { SongDAO dao = new SongDAO(); List <String> lyricsList = dao.getaAllLyrics(); string[] lines = { }; for (int i = 0; i < lyricsList.Count; i++) { lines = Regex.Split(lyricsList[i], " "); } GrammarBuilder grammarBuilder = new GrammarBuilder(); grammarBuilder.Culture = new System.Globalization.CultureInfo("en-US"); Choices commands = new Choices(); commands.Add(lines); grammarBuilder.Append(commands); Grammar grammar = new Grammar(grammarBuilder); return(grammar); }
private void InitializeSpeechRecognition() { try { var c = new Choices(_cache.Commands.Keys.ToArray()); var gb = new GrammarBuilder(c); var g = new Grammar(gb); _rec = new SpeechRecognitionEngine(); _rec.InitialSilenceTimeout = TimeSpan.FromSeconds(3); _rec.SpeechHypothesized += OnSpeechHypothesized; _rec.SpeechRecognitionRejected += OnSpeechRecognitionRejected; _rec.RecognizeCompleted += OnSpeechRecognized; _rec.LoadGrammarAsync(g); _rec.SetInputToDefaultAudioDevice(); _isEnabled = true; } catch { /* Speech Recognition hasn't been enabled on Windows */ } }
public Form1() { InitializeComponent(); // instanciation d'une reconnaissance vocales moteurReconnaissance = new SpeechRecognitionEngine(); // On précise que l'acquisition se fera sur le canal d'entrée audio par défaut (micro) moteurReconnaissance.SetInputToDefaultAudioDevice(); // On constuir le dictionnaire des mots à reconnaissance, ceux qui ne figurent pas dans cette liste ne seront pas reconnus formeChoisie = new Choices(new string[] { "carré", "cercle", "triangle" }); // On implante le dictionnaire dans le moteur de reconnaissance en utilisant un GrammarBuilder contraintesReconnaissance = new GrammarBuilder(formeChoisie); motsAReconnaitre = new Grammar(contraintesReconnaissance); moteurReconnaissance.LoadGrammarAsync(motsAReconnaitre); // Abonnement aux évènements liés à la reconnaissance vocale // Evènement déclencher lorsqu'un mot est reconnu moteurReconnaissance.SpeechRecognized += MoteurReconnaissance_SpeechRecognized2; // Evenement déclencheur lorqu'un mot n'est pas reconnu moteurReconnaissance.SpeechRecognitionRejected += MoteurReconnaissance_SpeechRecognitionRejected1; }
private async Task <CardSetting> PrepareInputSetting(DialogContext dc, InputState state, CancellationToken cancellationToken) { var cardSetting = new CardSetting { ChoiceList = Choices?.TryGetValue(dc.State).Value }; var actionName = ActionName?.TryGetValue(dc.State).Value; if (string.IsNullOrEmpty(actionName)) { actionName = "Submit"; } cardSetting.ActionName = actionName; cardSetting.OrientationType = OrientationType.GetValue(dc.State); cardSetting.Title = await GetPromptText(dc, state, cancellationToken); return(cardSetting); }
public ASR(ref Label recoText, ref Label affiche) { this.recoText = recoText; this.affiche = affiche; List <string> list_chemin = new List <string>() { "custom.txt", "test.txt" }; choice = new Choices(analyTxt(list_chemin)); this.gram_build = new GrammarBuilder(choice); for (int i = 0; i < 10; i++) { this.gram_build.Append(choice); } gram = new Grammar(gram_build); StartEngine(); }
private static Grammar BuildOperandsAdditionGrammar() { List <string> numbers = new List <string>(); for (int currOperand = 0; currOperand < 100; currOperand++) { numbers.Add(currOperand.ToString()); } Choices operandsChoices = new Choices(numbers.ToArray()); Choices operatorsChoices = new Choices(operators); GrammarBuilder additionGrammarBuilder = new GrammarBuilder(); additionGrammarBuilder.Append("calculate"); additionGrammarBuilder.Append(operandsChoices); additionGrammarBuilder.Append(operatorsChoices); additionGrammarBuilder.Append(operandsChoices); return(new Grammar(additionGrammarBuilder)); }
private void LoadGrammar() { Choices choices = new Choices(); List <string> phraseList = new List <string>(); for (int ii = 0; ii < grammarPhraseListBox.Items.Count; ii++) { string phrase = grammarPhraseListBox.Items[ii].ToString(); phraseList.Add(phrase); } choices.Add(phraseList.ToArray()); if (phraseList.Count > 0) { GrammarBuilder grammarBuilder = new GrammarBuilder(); CultureInfo currentCulture = new CultureInfo("en-US"); grammarBuilder.Culture = currentCulture; grammarBuilder.Append(choices); Grammar grammar = new Grammar(grammarBuilder); speechRecognitionEngine.LoadGrammar(grammar); } }
void Button2Click(object sender, EventArgs e) { Choices list = new Choices(); list.Add(new string[] { "on", "off" }); Grammar gr = new Grammar(new GrammarBuilder(list)); try { engine.RequestRecognizerUpdate(); engine.LoadGrammar(gr); engine.SpeechRecognized += new EventHandler <SpeechRecognizedEventArgs>(engine_SpeechRecognized); engine.SetInputToDefaultAudioDevice(); engine.RecognizeAsync(RecognizeMode.Multiple); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void InitializeSpeechRecognizer() { _speechRecognizer.UnloadAllGrammars(); _speechRecognizer.SpeechRecognized += speechRecognizer_SpeechRecognized; GrammarBuilder grammarBuilder = new GrammarBuilder(); Choices commandChoices = new Choices("medicine"); grammarBuilder.Append(commandChoices); Choices valueChoices = new Choices(); valueChoices.Add("Zinnat", "Lorivan", "Nocturno", "Zodorm", "Vader", "Brotizolam", "Norvasc", "Spirnolactone", "Zaldiar", "Tribmin", "Rispond", "Spirnolactone", "Ridazin", "bonserin", "Alloril", "Amlodipine", "Amlow", "Muscol"); grammarBuilder.Append(valueChoices); _speechRecognizer.LoadGrammar(new Grammar(grammarBuilder)); _speechRecognizer.SetInputToDefaultAudioDevice(); }
static void Main(string[] args) { NaoSpeechRecognitionEntities db = new NaoSpeechRecognitionEntities(); var userInput = db.UserInputs.ToList(); //List<string> userReplies = new List<string>(); Choices userReplies = new Choices(); foreach (var reply in userInput) { userReplies.Add(reply.Reply); } sre = new SpeechRecognitionEngine(); GrammarBuilder gb = new GrammarBuilder(); gb.Append(userReplies); Grammar g = new Grammar(gb); sre.LoadGrammar(g); sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized); sre.SetInputToDefaultAudioDevice(); // Start recognition. sre.Recognize(); Console.ReadKey(); }
/// <summary> /// Builds a grammar object from a dictionary of text-to-meaning mappings. /// </summary> /// <param name="dictionary">The dictionary with the mappings</param> /// <returns>The constructed grammar object</returns> public static Grammar BuildDictionaryGrammar(Dictionary <string, string> dictionary) { if (dictionary.Count == 0) { return(null); } Choices choices = new Choices(); foreach (KeyValuePair <string, string> entry in dictionary) { if (string.IsNullOrEmpty(entry.Key) && string.IsNullOrEmpty(entry.Value)) { continue; } SemanticResultValue phraseToSemanticsMapping = new SemanticResultValue(entry.Key, entry.Value); choices.Add(new GrammarBuilder(phraseToSemanticsMapping)); } return(new Grammar(new GrammarBuilder(choices))); }
public Grammar RandomNum() { Choices request = new Choices(new string[] { "give me a", "i need a", "pick a" }); Choices randomNum = new Choices(new string[] { "number", "random number" }); Choices loc = new Choices(new string[] { "from", "between", "within" }); Choices btw = new Choices(new string[] { "and", "to" }); GrammarBuilder findServices = new GrammarBuilder(); findServices.Append(request); findServices.Append(randomNum); findServices.Append(loc); findServices.Append(numbers); findServices.Append(btw); findServices.Append(numbers); // Create a Grammar object from the GrammarBuilder and load it to the recognizer. Grammar servicesGrammar = new Grammar(findServices); servicesGrammar.Name = "randomnum"; return(servicesGrammar); }
public static void DisplayMainMenu() { var title = "DESIDERATA"; var newGame = "NEW GAME"; var loadGame = "LOAD GAME"; var options = "OPTIONS"; var exit = "EXIT"; centerString(ref title, WindowWidth); centerString(ref newGame, WindowWidth); centerString(ref loadGame, WindowWidth); centerString(ref options, WindowWidth); centerString(ref exit, WindowWidth); Paragraph.Add(title); Choices.AddFirst(new Choice(newGame, AManApproaches)); Choices.AddAfter(Choices.Last, new Choice(loadGame, () => { })); Choices.AddAfter(Choices.Last, new Choice(options, OptionsMenu)); Choices.AddAfter(Choices.Last, new Choice(exit, () => { })); DisplayChoices(true); }
private void Form1_Load(object sender, EventArgs e) { SpeechRecognizer recognizer = new SpeechRecognizer(); Choices commands = new Choices(); commands.Add(new string[] { "say hello", "print my name" }); // Create a GrammarBuilder object and append the Choices object. GrammarBuilder gBuilder = new GrammarBuilder(); gBuilder.Append(commands); // Create the Grammar instance and load it into the speech recognition engine. Grammar grammar = new Grammar(gBuilder); recEngine.LoadGrammarAsync(grammar); recEngine.SetInputToDefaultAudioDevice(); recEngine.SpeechRecognized += recEngine_SpeechRecognized; // Register a handler for the SpeechRecognized event. }
private void LoadGrammar(SpeechRecognitionEngine speechRecognitionEngine) { // Build a simple grammar of shapes, colors, and some simple program control var single = new Choices(); foreach (var phrase in this.gameplayPhrases) { single.Add(phrase.Key); } var allChoices = new Choices(); allChoices.Add(single); // This is needed to ensure that it will work on machines with any culture, not just en-us. var gb = new GrammarBuilder { Culture = speechRecognitionEngine.RecognizerInfo.Culture }; gb.Append(allChoices); var g = new Grammar(gb); speechRecognitionEngine.LoadGrammar(g); speechRecognitionEngine.SpeechRecognized += this.SreSpeechRecognized; speechRecognitionEngine.SpeechHypothesized += this.SreSpeechHypothesized; }
void prepareWordRecognitionEngine(String culture, String[] wordlist) { System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo(culture); sr = new SpeechRecognitionEngine(cultureInfo); sr.SetInputToDefaultAudioDevice(); Choices colors = new Choices(); colors.Add(wordlist); GrammarBuilder gb = new GrammarBuilder(); gb.Culture = cultureInfo; gb.Append(colors); //Create the Grammar instance. Grammar g = new Grammar(gb); //Grammar g = new DictationGrammar(); sr.LoadGrammar(g); //sr.LoadGrammar(new DictationGrammar()); }
public Form1() { InitializeComponent(); SpeechRecognitionEngine reco = new SpeechRecognitionEngine(); Choices list = new Choices(); s.SpeakAsync("hoşgeldiniz efendim"); list.Add(new string[] { "merhaba", "nasılsın", "internet", "video", "mozilla", "bye", "kapat", "napıyorsun" }); Grammar gm = new Grammar(new GrammarBuilder(list)); try { reco.RequestRecognizerUpdate(); reco.LoadGrammar(gm); reco.SpeechRecognized += Reco_SpeechRecognized; reco.SetInputToDefaultAudioDevice(); reco.RecognizeAsync(RecognizeMode.Multiple); } catch { } }
private void speechInput() { assistatantAgentSpeaker.Volume = 100; srec.SetInputToDefaultAudioDevice(); Choices speechCommand = new Choices(); speechCommand.Add(new string[] { "Help me", "Cindy" }); GrammarBuilder gbr = new GrammarBuilder(); gbr.Append(speechCommand); Grammar g = new Grammar(gbr); srec.LoadGrammar(g); // An Event handler for AudioLevelUpdated event. srec.AudioLevelUpdated += new EventHandler <System.Speech.Recognition.AudioLevelUpdatedEventArgs>(check_audioLevel); srec.SpeechRecognized += new EventHandler <System.Speech.Recognition.SpeechRecognizedEventArgs>(auto_SpeechRecognized); // Start recognition. srec.RecognizeAsync(System.Speech.Recognition.RecognizeMode.Multiple); }
private void button1_Click(object sender, EventArgs e) // when "Listen" button is clicked { Choices slist = new Choices(); slist.Add(new string[] { "call", "call yusha", "call ami", "parho surah al fatiha", "parho", "stop", "recite surah al fatiha", "surah al fatiha", "search facebook", "search mehran", "search", "jarvis", "google", "open", "open facebook", "open youtube", "open twitter", "open google" }); Grammar gr = new Grammar(new GrammarBuilder(slist)); try { sre.RequestRecognizerUpdate(); sre.LoadGrammar(gr); sre.SpeechRecognized += sre_SpeechRecognized; //new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized); sre.SetInputToDefaultAudioDevice(); sre.RecognizeAsync(RecognizeMode.Multiple); // MessageBox.Show("done"); } catch { return; } }
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(); }
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; } }