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);
}
}
}