The event does not fire up i.e. no message box is shown up on speaking the words. Not sure about whether even the engine started or not.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Speech;
using System.Speech.Recognition;
using System.Speech.Synthesis;
using System.Threading;
namespace Summerproject_trial
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
private SpeechRecognitionEngine recEngine = new SpeechRecognitionEngine();
public MainWindow()
{
InitializeComponent();
Choices mychoices = new Choices();
mychoices.Add(new string[] {"Ok","Test","Hello"});
GrammarBuilder gb = new GrammarBuilder();
gb.Append(mychoices);
Grammar mygrammar = new Grammar(gb);
recEngine.LoadGrammarAsync(mygrammar);
recEngine.SpeechRecognized += new EventHandler(recEngine_SpeechRecognized);
recEngine.SetInputToDefaultAudioDevice();
}
void recEngine_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
MessageBox.Show("You said: "+e.Result.Text);
//throw new NotImplementedException();
}
}
}
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ankur MistryPosted Dec 5, 2015, 11:42 AM
Sanju SinghPosted Dec 20, 2014, 4:20 AM