SpeechDetectedEventArgs.AudioPosition Property

Gets the position in the audio stream where speech was detected.

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

public TimeSpan AudioPosition { get; }

Property Value

Type: System.TimeSpan
Returns the location of a detected phrase within the speech buffer of a recognition engine.

In the example below, a handler is created for SpeechDetected events which initializes a display every time speech is detected and displays status information, including audio position.

_recognizer.SpeechDetected +=
  delegate(object sender, SpeechDetectedEventArgs eventArgs) 
  {

    // Clear previous recognition information.
    _audioDeviceStatusLabel.Enabled = true;
    _audioDeviceStatusLabel.Visible = true;
    Utils.DisplayAudioInputFormat(_audioStateLabel, _recognizer);
    Utils.DisplayRecognizerState(_recognizerStateLabel, _recognizer.State);
    Utils.DisplaySpeechDetected(_speechDetectedLabel, eventArgs.AudioPosition);
  };
Show: