1 out of 1 rated this helpful - Rate this topic

SpeechUI Class

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)
public class SpeechUI

The members of SpeechUI are used to indicate exact feed back to the end user through the Speech platform user interface.

An application can return arbitrary text and success/failure information using SpeechUI.

The example below is a handler for a 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 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);
        }
    }
};
System.Object
  System.Speech.Recognition.SpeechUI
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

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

.NET Framework

Supported in: 3.5, 3.0
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ