Click here to Skip to main content
15,895,794 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
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...
regards

C#
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)
        {
            
         }            
    }
}
Posted
Updated 27-Apr-14 23:49pm
v3
Comments
[no name] 28-Apr-14 3:52am    
refer this code http://www.codeproject.com/Articles/483347/Speech-recognition-speech-to-text-text-to-speech-a
[no name] 28-Apr-14 3:53am    
http://www.c-sharpcorner.com/uploadfile/ssrinivas/speeechrecognitionusingcsharp11222005054918am/speeechrecognitionusingcsharp.aspx This will solve your problem
Aftab Khan 28-Apr-14 4:11am    
i have tried the codeproject article and the application which u r referring to(WWW.c-sharp corner.com)as a reference when i was starting this project.. but these applications are meant for text to speech basis. i am working on to speak a button's name and the button should be activated and perform the respective operation.thanks anyways.. :)
Rock (Multithreaded) 28-Apr-14 6:30am    
This Solution contains details and sample project.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900