SpeechUI Class
.NET Framework 3.0
Provides text and status information to the operating system in speech user interface to display to the user.
Namespace: System.Speech.Recognition
Assembly: System.Speech (in system.speech.dll)
Assembly: System.Speech (in system.speech.dll)
The example below is a handler for a Grammar.SpeechRecognized event used by a Grammar designed to handle password input for the form "My password is …".
If a password is not present, or not valid, SendTextFeedback is used to send error information to the 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); }
}
};
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: