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.

C#
public static bool SendTextFeedback(System.Speech.Recognition.RecognitionResult result, string feedback, bool isSuccessfulAction);

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

Proizvod Verzije
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)