Click here to Skip to main content
15,849,328 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi, I am having a problem in my project here, i want to save the name of the person when the computer ask for its name! to text file in c:\.
can you please guide me on this, if i need to create a separate grammar for the names.
Thanks
namespace mypro
{
    public partial class MainWindow : Window
    {
        SpeechRecognitionEngine en = new SpeechRecognitionEngine();

        public MainWindow()
        {
            InitializeComponent();

            en.SetInputToDefaultAudioDevice();

            Choices ch = new Choices("Hello","hey");
            Grammar h = new Grammar(ch.ToGrammarBuilder());
            h.Name = "ha";

   en.LoadGrammarAsync(h);

   en.RecognizeAsync(RecognizeMode.Multiple);

  en.SpeechRecognized += new EventHandler<Speech Recognized EventArgs>(en_SpeechRecognized)
            
        }


public void en_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if (e.Result.Grammar.Name == "ha")
            {
                switch (e.Result.Text)
                {
                         
                    case "Hello":
                        Say("hi, may i know your name?");
                         break;
                    case "hey":
                         Say("hi, may i know your name?");
                        break;
                }
            }
        }

    public void Say(string input)
        {
            var s = new SpeechSynthesizer();
            var sa = new Prompt(input);
            s.Speak(sa);
            
        }

       
    }
}
Posted
Updated 18-Apr-13 10:12am
v2

If you follow this thread youll find your answer:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/97c58d33-d9d5-4a2c-867f-90019cdfff77/[^]

It also depends on what language you are thinking of using though.
 
Share this answer
 
recongition system will only recognize those words which are already in the grammar file
means you can not directly add names to the grammar files
 
Share this answer
 
Nope , none of above solutions helped me! Anybody else has anything to add. please help me find a solution.
 
Share this answer
 

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