SpeechRecognizer class

Performs speech recognition from microphone, file, or other audio input streams, and gets transcribed text as result.

Extends

Constructors

SpeechRecognizer(SpeechConfig, AudioConfig)

SpeechRecognizer constructor.

Properties

authorizationToken

Gets the authorization token used to communicate with the service.

canceled

The event canceled signals that an error occurred during recognition.

endpointId

Gets the endpoint id of a customized speech model that is used for speech recognition.

internalData
outputFormat

Gets the output format of recognition.

properties

The collection of properties and their values defined for this SpeechRecognizer.

recognized

The event recognized signals that a final recognition result is received.

recognizing

The event recognizing signals that an intermediate recognition result is received.

speechRecognitionLanguage

Gets the spoken language of recognition.

telemetryEnabled

This method returns the current state of the telemetry setting.

Inherited Properties

sessionStarted

Defines event handler for session started events.

sessionStopped

Defines event handler for session stopped events.

speechEndDetected

Defines event handler for speech stopped events.

speechStartDetected

Defines event handler for speech started events.

Methods

close(() => void, (error: string) => void)

closes all external resources held by an instance of this class.

dispose(boolean)

Disposes any resources held by the object.

FromConfig(SpeechConfig, AutoDetectSourceLanguageConfig, AudioConfig)

SpeechRecognizer constructor.

recognizeOnceAsync((e: SpeechRecognitionResult) => void, (e: string) => void)

Starts speech recognition, and stops after the first utterance is recognized. The task returns the recognition text as result. Note: RecognizeOnceAsync() returns when the first utterance has been recognized, so it is suitable only for single shot recognition like command or query. For long-running recognition, use StartContinuousRecognitionAsync() instead.

startContinuousRecognitionAsync(() => void, (e: string) => void)

Starts speech recognition, until stopContinuousRecognitionAsync() is called. User must subscribe to events to receive recognition results.

startKeywordRecognitionAsync(KeywordRecognitionModel, () => void, (e: string) => void)

Starts speech recognition with keyword spotting, until stopKeywordRecognitionAsync() is called. User must subscribe to events to receive recognition results. Note: Key word spotting functionality is only available on the Speech Devices SDK. This functionality is currently not included in the SDK itself.

stopContinuousRecognitionAsync(() => void, (e: string) => void)

Stops continuous speech recognition.

stopKeywordRecognitionAsync(() => void)

Stops continuous speech recognition. Note: Key word spotting functionality is only available on the Speech Devices SDK. This functionality is currently not included in the SDK itself.

Inherited Methods

enableTelemetry(boolean)

This method globally enables or disables telemetry.

Constructor Details

SpeechRecognizer(SpeechConfig, AudioConfig)

SpeechRecognizer constructor.

new SpeechRecognizer(speechConfig: SpeechConfig, audioConfig?: AudioConfig)

Parameters

speechConfig
SpeechConfig

an set of initial properties for this recognizer

audioConfig
AudioConfig

An optional audio configuration associated with the recognizer

Property Details

authorizationToken

Gets the authorization token used to communicate with the service.

string authorizationToken

Property Value

string

Authorization token.

canceled

The event canceled signals that an error occurred during recognition.

public canceled: (sender: Recognizer, event: SpeechRecognitionCanceledEventArgs) => void

Property Value

(sender: Recognizer, event: SpeechRecognitionCanceledEventArgs) => void

endpointId

Gets the endpoint id of a customized speech model that is used for speech recognition.

string endpointId

Property Value

string

the endpoint id of a customized speech model that is used for speech recognition.

internalData

object internalData

Property Value

object

outputFormat

Gets the output format of recognition.

OutputFormat outputFormat

Property Value

The output format of recognition.

properties

The collection of properties and their values defined for this SpeechRecognizer.

PropertyCollection properties

Property Value

The collection of properties and their values defined for this SpeechRecognizer.

recognized

The event recognized signals that a final recognition result is received.

public recognized: (sender: Recognizer, event: SpeechRecognitionEventArgs) => void

Property Value

(sender: Recognizer, event: SpeechRecognitionEventArgs) => void

recognizing

The event recognizing signals that an intermediate recognition result is received.

public recognizing: (sender: Recognizer, event: SpeechRecognitionEventArgs) => void

Property Value

(sender: Recognizer, event: SpeechRecognitionEventArgs) => void

speechRecognitionLanguage

Gets the spoken language of recognition.

string speechRecognitionLanguage

Property Value

string

The spoken language of recognition.

telemetryEnabled

This method returns the current state of the telemetry setting.

static boolean telemetryEnabled

Property Value

boolean

true if the telemetry is enabled, false otherwise.

Inherited Property Details

sessionStarted

Defines event handler for session started events.

public sessionStarted: (sender: Recognizer, event: SessionEventArgs) => void

Property Value

(sender: Recognizer, event: SessionEventArgs) => void

Inherited From Recognizer.sessionStarted

sessionStopped

Defines event handler for session stopped events.

public sessionStopped: (sender: Recognizer, event: SessionEventArgs) => void

Property Value

(sender: Recognizer, event: SessionEventArgs) => void

Inherited From Recognizer.sessionStopped

speechEndDetected

Defines event handler for speech stopped events.

public speechEndDetected: (sender: Recognizer, event: RecognitionEventArgs) => void

Property Value

(sender: Recognizer, event: RecognitionEventArgs) => void

Inherited From Recognizer.speechEndDetected

speechStartDetected

Defines event handler for speech started events.

public speechStartDetected: (sender: Recognizer, event: RecognitionEventArgs) => void

Property Value

(sender: Recognizer, event: RecognitionEventArgs) => void

Inherited From Recognizer.speechStartDetected

Method Details

close(() => void, (error: string) => void)

closes all external resources held by an instance of this class.

function close(cb?: () => void, errorCb?: (error: string) => void)

Parameters

cb

() => void

errorCb

(error: string) => void

dispose(boolean)

Disposes any resources held by the object.

function dispose(disposing: boolean): Promise<void>

Parameters

disposing

boolean

true if disposing the object.

Returns

Promise<void>

FromConfig(SpeechConfig, AutoDetectSourceLanguageConfig, AudioConfig)

SpeechRecognizer constructor.

static function FromConfig(speechConfig: SpeechConfig, autoDetectSourceLanguageConfig: AutoDetectSourceLanguageConfig, audioConfig?: AudioConfig): SpeechRecognizer

Parameters

speechConfig
SpeechConfig

an set of initial properties for this recognizer

autoDetectSourceLanguageConfig
AutoDetectSourceLanguageConfig

An source language detection configuration associated with the recognizer

audioConfig
AudioConfig

An optional audio configuration associated with the recognizer

Returns

recognizeOnceAsync((e: SpeechRecognitionResult) => void, (e: string) => void)

Starts speech recognition, and stops after the first utterance is recognized. The task returns the recognition text as result. Note: RecognizeOnceAsync() returns when the first utterance has been recognized, so it is suitable only for single shot recognition like command or query. For long-running recognition, use StartContinuousRecognitionAsync() instead.

function recognizeOnceAsync(cb?: (e: SpeechRecognitionResult) => void, err?: (e: string) => void)

Parameters

cb

(e: SpeechRecognitionResult) => void

Callback that received the SpeechRecognitionResult.

err

(e: string) => void

Callback invoked in case of an error.

startContinuousRecognitionAsync(() => void, (e: string) => void)

Starts speech recognition, until stopContinuousRecognitionAsync() is called. User must subscribe to events to receive recognition results.

function startContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void)

Parameters

cb

() => void

Callback invoked once the recognition has started.

err

(e: string) => void

Callback invoked in case of an error.

startKeywordRecognitionAsync(KeywordRecognitionModel, () => void, (e: string) => void)

Starts speech recognition with keyword spotting, until stopKeywordRecognitionAsync() is called. User must subscribe to events to receive recognition results. Note: Key word spotting functionality is only available on the Speech Devices SDK. This functionality is currently not included in the SDK itself.

function startKeywordRecognitionAsync(model: KeywordRecognitionModel, cb?: () => void, err?: (e: string) => void)

Parameters

model
KeywordRecognitionModel

The keyword recognition model that specifies the keyword to be recognized.

cb

() => void

Callback invoked once the recognition has started.

err

(e: string) => void

Callback invoked in case of an error.

stopContinuousRecognitionAsync(() => void, (e: string) => void)

Stops continuous speech recognition.

function stopContinuousRecognitionAsync(cb?: () => void, err?: (e: string) => void)

Parameters

cb

() => void

Callback invoked once the recognition has stopped.

err

(e: string) => void

Callback invoked in case of an error.

stopKeywordRecognitionAsync(() => void)

Stops continuous speech recognition. Note: Key word spotting functionality is only available on the Speech Devices SDK. This functionality is currently not included in the SDK itself.

function stopKeywordRecognitionAsync(cb?: () => void)

Parameters

cb

() => void

Callback invoked once the recognition has stopped.

Inherited Method Details

enableTelemetry(boolean)

This method globally enables or disables telemetry.

static function enableTelemetry(enabled: boolean)

Parameters

enabled

boolean

Global setting for telemetry collection. If set to true, telemetry information like microphone errors, recognition errors are collected and sent to Microsoft. If set to false, no telemetry is sent to Microsoft.

Inherited From Recognizer.enableTelemetry