Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

EmulateRecognizeCompletedEventArgs Class

Provides data for the EmulateRecognizeCompleted event.

Inheritance Hierarchy

System.Object
  System.EventArgs
    System.ComponentModel.AsyncCompletedEventArgs
      Microsoft.Speech.Recognition.EmulateRecognizeCompletedEventArgs

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

'Declaration
Public Class EmulateRecognizeCompletedEventArgs _
    Inherits AsyncCompletedEventArgs
'Usage
Dim instance As EmulateRecognizeCompletedEventArgs
public class EmulateRecognizeCompletedEventArgs : AsyncCompletedEventArgs

Remarks

An instance of EmulateRecognizeCompletedEventArgs is created when the SpeechRecognitionEngine object raises the EmulateRecognizeCompleted event. To obtain information about the result of recognition, access the Result property in the handler for the event.

Emulation is a process that provides text, instead of audio, as the input to a speech recognition engine. To bypass the audio inputs for a SpeechRecognitionEngine object during emulation, use the SetInputToNull() method.

If the speech recognition engine encounters an exception during the recognition operation, the Error property is set to the exception and the Result property is set to a null reference (Nothing in Visual Basic).

EmulateRecognizeCompletedEventArgs derives from AsyncCompletedEventArgs.

Examples

The following example adds an event handler for the EmulateRecognizeCompleted event to a SpeechRecognitionEngine. The handler gets the recognized text from the Result property.

private SpeechRecognitionEngine sre;

// Initialize the speech recognition engine. 
private void Initialize()
{
  sre = new SpeechRecognitionEngine();

  // Add a handler for the EmulateRecognizeCompleted event.
  sre.EmulateRecognizeCompleted += new EventHandler<EmulateRecognizeCompletedEventArgs>(sre_EmulateRecognizeCompleted);

  // Add other initialization code here.
}

// Handle the EmulateRecognizeCompleted event. 
void sre_EmulateRecognizeCompleted(object sender, EmulateRecognizeCompletedEventArgs e)
{
  if (e.Result == null) return;

  string phrase = e.Result.Text;

  // Add event handler code here.
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

EmulateRecognizeCompletedEventArgs Members

Microsoft.Speech.Recognition Namespace

Result

EmulateRecognizeCompleted

EmulateRecognize

EmulateRecognizeAsync

SpeechRecognitionEngine

AsyncCompletedEventArgs