Κοινή χρήση μέσω


SpeechUI.SendTextFeedback(RecognitionResult, String, Boolean) Method

Definition

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

public:
 static bool SendTextFeedback(System::Speech::Recognition::RecognitionResult ^ result, System::String ^ feedback, bool isSuccessfulAction);
public static bool SendTextFeedback (System.Speech.Recognition.RecognitionResult result, string feedback, bool isSuccessfulAction);
static member SendTextFeedback : System.Speech.Recognition.RecognitionResult * string * bool -> bool
Public Shared Function SendTextFeedback (result As RecognitionResult, feedback As String, isSuccessfulAction As Boolean) As Boolean

Parameters

result
RecognitionResult

A valid RecognitionResult instance.

feedback
String

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

isSuccessfulAction
Boolean

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

Returns

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.

Examples

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);  
  }  
  else  
  {  
    RecognizedAudio pwdAudio = result.GetAudioForWordRange(  
              result.Words[3],  
              result.Words[result.Words.Count - 1]);  
    MemoryStream pwdMemoryStream = new MemoryStream();  
    pwdAudio.WriteToAudioStream(pwdMemoryStream);  
    if (!IsValidPwd(pwdMemoryStream))   
    {  
      string badPwd = System.IO.Path.GetTempPath() + "BadPwd" +   
               (new Random()).Next().ToString() + ".wav";  
      FileStream waveStream = new FileStream(badPwd, FileMode.Create);  
      pwdAudio.WriteToWaveStream(waveStream);  
      waveStream.Flush();  
      waveStream.Close();  
      SpeechUI.SendTextFeedback(eventArgs.Result, "Invalid Password", false);  
    }  
  }  
};  

Remarks

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.

Applies to