Share via


SpeechUI.SendTextFeedback(RecognitionResult, String, Boolean) メソッド

定義

認識操作の状態について、音声プラットフォーム ユーザー インターフェイスに状態と説明テキストを送信します。

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

パラメーター

result
RecognitionResult

有効な RecognitionResult のインスタンス。

feedback
String

Stringresult を生成した認識操作に関するコメントを含む RecognitionResult

isSuccessfulAction
Boolean

アプリケーションが認識操作を成功と判断したかどうかを示す bool

戻り値

メソッドに提供された情報 (Feedback、および isSuccessfulAction) が Speech プラットフォームのユーザー インターフェイスに対して正常に公開された場合は true、操作に失敗した場合は false

次の例は、イベントのハンドラーです SpeechRecognized 。 このイベントは、フォーム "My password is ..." のパスワード入力を処理するように設計された によって Grammar 使用されます。

パスワードが存在しないか無効な場合は、 SendTextFeedback を使用して、音声プラットフォームのユーザー インターフェイスにエラー情報を送信します。

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

注釈

SendTextFeedback は、入力が認識された場合でも、認識操作が特定の条件を満たさなかったことを示すために使用できます。

たとえば、入力が完全に認識されたが、検証情報が間違っていたセキュリティ コード情報の検証があります。

適用対象