Click here to Skip to main content
11,492,523 members (60,352 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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 16-Apr-13 22:39pm
Edited 18-Apr-13 10:12am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Nope , none of above solutions helped me! Anybody else has anything to add. please help me find a solution.
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 399
1 Maciej Los 266
2 KarstenK 210
3 CPallini 208
4 Sascha Lefèvre 195
0 Sergey Alexandrovich Kryukov 9,943
1 OriginalGriff 8,610
2 Sascha Lefèvre 3,609
3 Maciej Los 3,372
4 Richard Deeming 2,440


Advertise | Privacy | Mobile
Web01 | 2.8.150520.1 | Last Updated 18 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100