Export (0) Print
Expand All

SpeechUI.SendTextFeedback Method

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
)

Parameters

result
Type: System.Speech.Recognition.RecognitionResult

A valid RecognitionResult instance.

feedback
Type: System.String

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

isSuccessfulAction
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);
  }
  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);
    }
  }
};

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft