C# Speech Recognition - Is This What the User Said

Get user input from Speech?

It does not look like in your situation e.Result.Text represents something that you can enumerate: you are checking the words that start the text, not the text in its entirety. In cases like this, you should not use a switch, and go for a chain of if-then-elses instead:

var text = e.Result.Text;
if (text.StartsWith("test")) {
writeConsolas("What do you want me to test?", me);
} else if (text.StartsWith("change username")) {
writeConsolas("What do you want to be called?", me);
} else if (text.StartsWith("exit")) {
writeConsolas("Do you wish me to exit?", me);
} else if (text.StartsWith("call me")) {
// Here you have the whole text. Chop off the "call me" part,
// using Substring(), and do whatever you need to do with the rest of it
} else
...

How do you make c# ask for a confirmation?

I'll express my answer using the high-level algorithm, for clarity.

  1. Wait to receive "Call Mark"
  2. Speak "Are you sure?"
  3. If the answer is "yes", then call Mark.

In code:

if (speech = "CALL MARK) {
var string input = Api.DetectSpeech(Source.Microphone);
if (input = "YES") {
Phone.DialNumber(Contacts.Mark);
}
}

Partial voice recognition

This functionality is called "keyword spotting". Usually you can not perform keyword spotting with speech recognition engine, you need a specific spotting package. The key issue is that engine should compare two outcomes constantly - word is found and word is not found. Speech recognition only looks for the words which are in grammar and doesn't consider other sounds. Spotting just requires a different algorithm.

There is a workaround to add many possible syllables or other sounds into speech recognition grammar and hope that engine will find them instead of keyword, but it's not a very good solution in terms of accuracy compared to specific keyword spotter.

If you are not closely tied to Microsoft's engine and you need a common language like US English or French you can implement keyword spotting with open source software toolkits for speech recognition like CMUSphinx.



Related Topics



Leave a reply



Submit