SpeechUI.SendTextFeedback Method (RecognitionResult, String, Boolean)


Sends status and descriptive text to the Speech platform user interface about the status of a recognition operation.

Namespace:   System.Speech.Recognition
Assembly:  System.Speech (in System.Speech.dll)

public static bool SendTextFeedback(
	RecognitionResult result,
	string feedback,
	bool isSuccessfulAction


Type: System.Speech.Recognition.RecognitionResult

A valid RecognitionResult instance.

Type: System.String

A String containing a comment about the recognition operation that produced the RecognitionResultresult.

Type: System.Boolean

A bool indicating whether the application deemed the recognition operation a success.

Return Value

Type: System.Boolean

true if the information provided to the method (Feedback, and isSuccessfulAction) was successfully made available to the Speech platform user interface, and false if the operation failed.

SendTextFeedback can be used to indicate that a recognition operation failed to meet certain criteria, even if the input was recognized.

An example is the verification of security code information, where the input was fully recognized, but the verification information was wrong.

The following example is a handler for a SpeechRecognized event. This event is used by a Grammar that is designed to handle password input of the form, "My password is …".

If a password is not present, or not valid, SendTextFeedback is used to send error information to the Speech platform user interface.

grammar.SpeechRecognized +=
delegate(object sender, SpeechRecognizedEventArgs eventArgs) 
  SemanticValue semantics = eventArgs.Result.Semantics;
  RecognitionResult result=eventArgs.Result;

  if (!semantics.ContainsKey("Password")) 
    SpeechUI.SendTextFeedback(eventArgs.Result, "No Password Provided", false);
    RecognizedAudio pwdAudio = result.GetAudioForWordRange(
              result.Words[result.Words.Count - 1]);
    MemoryStream pwdMemoryStream = new MemoryStream();
    if (!IsValidPwd(pwdMemoryStream)) 
      string badPwd = System.IO.Path.GetTempPath() + "BadPwd" + 
               (new Random()).Next().ToString() + ".wav";
      FileStream waveStream = new FileStream(badPwd, FileMode.Create);
      SpeechUI.SendTextFeedback(eventArgs.Result, "Invalid Password", false);

.NET Framework
Available since 3.0
Return to top