Share via


Note

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

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)

Syntax

'Declaration
Public ReadOnly Property AudioPosition As TimeSpan
    Get
'Usage
Dim instance As SpeechDetectedEventArgs
Dim value As TimeSpan

value = instance.AudioPosition
public TimeSpan AudioPosition { get; }

Property Value

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

Examples

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

See Also

Reference

SpeechDetectedEventArgs Class

SpeechDetectedEventArgs Members

Microsoft.Speech.Recognition Namespace

SpeechDetectedEventArgs

AudioStateChanged

SpeechDetected