Beginning MS Agent: Part 3
What if you have lots of commands with voice input commands that are very similar? Well there is a way to only call a command if the agent clearly recognizes the spoken input. Consider our code from above, modified.
Private Sub Agent1_Command(ByVal UserInput as Object) Dim BadConfidence BadConfidence = 10 If (UserInput.Confidence <= -40) Then ' Bad Recognition Exit Sub ElseIf (UserInput.Alt1Name <> "") And _ Abs(Abs(UserInput.Alt1Confidence) - _ Abs(UserInput.Confidence)) _ < BadConfidence Then ' Bad Confidence - too close to another command Exit Sub ElseIf (UserInput.Alt2Name <> "") And _ Abs(Abs(UserInput.Alt2Confidence) - _ Abs(UserInput.Confidence)) _ < BadConfidence Then ' Bad Confidence - too close to another command Exit Sub Else ' High Confidence Select Case UserInput.Name Case "ACO" Agent1.PropertySheet.Visible = True End Select End IfEnd Sub
First of all, many thanks to the MASH program, which is where I first learned of this code example. For a more detailed description of this code, please visit the MASH site. Basically what we have done above is define how exact the spoken input needs to be in order to call the command. You can alter the numbers to adjust how sensitive the speech must be. A BadConfidence number of about 10 is a good starting number to limit the speech recognition engine's mistakes.
Page 4 of 6