I'm building an application that recognizes multiple words from a user; thus putting together a sentence using the words recognized.
Here's what I have as of now:
namespace SentenceRecognitionFramework__v1_
{
public partial class Form1 : Form
{
SpeechRecognitionEngine recog = new SpeechRecognitionEngine();
SpeechSynthesizer sp = new SpeechSynthesizer();
public Form1()
{
InitializeComponent();
}
private void btnListen_Click(object sender, EventArgs e)
{
Choices sList = new Choices();
sList.Add(new String[] { "what","is", "a", "car" });
Grammar gr = new Grammar(new GrammarBuilder(sList));
recog.RequestRecognizerUpdate();
recog.LoadGrammar(gr);
recog.SpeechRecognized += sRecognize_SpeechRecognized;
recog.SetInputToDefaultAudioDevice();
recog.RecognizeAsync(RecognizeMode.Multiple);
recog.SpeechRecognitionRejected += sRecognize_SpeechRecognitionRejected;
}
private void sRecognize_SpeechRecognitionRejected(object sender, SpeechRecognitionRejectedEventArgs e)
{
sentenceBox.Text = "Sorry, I couldn't recognize";
}
private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
sentenceBox.Text = e.Result.Text.ToString();
}
}
}
HOWEVER, this code will only recognize one word at a time. Even if I edit my code to do this:
private void sRecognize_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
sentenceBox.Text = sentenceBox.Text + " " + e.Result.Text.ToString();
}
The application cannot continuously recognize words when I utter the words "What is a car" continuously without having breaks when I speak them out.
What changes can I make in order for the program to recognize an entire sentence built using those words defined, without having to have speech breaks when uttering the sentence?
Output required:
I utter the sentence: What is a car
Application displays: What is a car
PERFECT Example: Google Speech Recognition Google develops a sentence using the words available in their word library
Thank you kindly :)