hello,i am working on a project called interactive ATM with the functionality of speech commands. i am stuck at a point where i speak a particular option but it does not redirect to that respective \ "option" window.the event in which the recognizer should redirect me to that windows is not firing. i am giving the code below, please help me out...regardsusing 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) { } }} 解决方案 这篇关于如何在Widows表单中启用语音识别事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!