I have just started trying out the Windows Speech to Text capabilities in C# .Net. I currently have the basics working (IE - Say something, and it will provide output based on what you say). However, I am struggling to figure out how to actually recieve user input as a variable.
What I mean by this, is that for example. If the user says:
"Call me John"
Then I want to be able to take the word John
as a variable and then store that as say, the persons username.
My current SpeechRecognized
event is as follows:
void zeusSpeechRecognised(object sender, SpeechRecognizedEventArgs e)
{
writeConsolas(e.Result.Text, username);
switch (e.Result.Grammar.RuleName)
{
case "settingsRules":
switch (e.Result.Text)
{
case "test":
writeConsolas("What do you want me to test?", me);
break;
case "change username":
writeConsolas("What do you want to be called?", me);
break;
case "exit":
writeConsolas("Do you wish me to exit?", me);
break;
}
break;
}
}
NB:writeConsolas
is just a glorified append line to a RichTextBox
.
I would like to add another case
which does the following:
case "call me"
username = e.Result.GetWordFollowingCallMe() //Obv not a method, but thats the general idea.
break;
Obviously, there is no such method, but that is the general idea that I wish to implement. Is there a way to search for specific phrases (IE: Call me
) and take the following word?
EDIT: I should note, that the e.Result.Text only returns words that it can match to Text in the dictionary.