using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Speech.Recognition; using SpeechLib; using System.Speech.Synthesis; using System.Threading; namespace SpeechRec { public partial class Form1 : Form { public Form1() { SpeechRecognitionEngine _recognizer = new SpeechRecognitionEngine(); InitializeComponent(); panela.Visible=true; panelb.Visible = false; panelc.Visible = false; paneld.Visible = false; _recognizer = new SpeechRecognitionEngine(); _recognizer.SetInputToDefaultAudioDevice(); Choices commandChoices = new Choices("Services", "mini statement", "mobile registration"); GrammarBuilder gb = new GrammarBuilder(); gb.Append(commandChoices); Grammar g = new Grammar(gb); _recognizer.LoadGrammar(g); _recognizer.RecognizeAsync(RecognizeMode.Multiple); _recognizer.SpeechRecognized += (s, args) => { string line = ""; string command = Regex.Replace(line,"start", "").Trim(); switch (command) { case "Services": panelb.Visible = true; panela.Visible = false; break; case "mini statement": panelc.Visible=true; break; case "mobile registration": paneld.Visible = true; break; default: break; } }; } private void Form1_Load(object sender, EventArgs e) { } private void button1_DoubleClick(object sender, EventArgs e) { } private void Button4_Click(object sender, EventArgs e) { } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)