SpeechConfig class

Speech configuration.

Properties

authorizationToken

Gets the authorization token. Gets/Sets the authorization token. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token.

endpointId

Gets the endpoint ID of a customized speech model that is used for speech recognition. Gets/Sets the endpoint ID of a customized speech model that is used for speech recognition.

outputFormat

Gets speech recognition output format (simple or detailed). Note: This output format is for speech recognition result, use [SpeechConfig.speechSynthesisOutputFormat] to get synthesized audio output format. Gets/Sets speech recognition output format (simple or detailed). Note: This output format is for speech recognition result, use [SpeechConfig.speechSynthesisOutputFormat] to set synthesized audio output format.

region
speechRecognitionLanguage

Returns the configured language. Gets/Sets the input language.

speechSynthesisLanguage

Gets the language of the speech synthesizer. Sets the language of the speech synthesizer.

speechSynthesisOutputFormat

Gets the speech synthesis output format. Sets the speech synthesis output format (e.g. Riff16Khz16BitMonoPcm).

speechSynthesisVoiceName

Gets the voice of the speech synthesizer. Sets the voice of the speech synthesizer. (see available voices).

subscriptionKey

Methods

close()

Closes the configuration.

enableAudioLogging()
enableDictation()
fromAuthorizationToken(string, string)

Creates an instance of the speech factory with specified initial authorization token and region. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Note: Please use a token derived from your LanguageUnderstanding subscription key in case you want to use the Intent recognizer. As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created. For recognizers that have been created before, you need to set authorization token of the corresponding recognizer to refresh the token. Otherwise, the recognizers will encounter errors during recognition.

fromEndpoint(URL, string)

Creates an instance of the speech config with specified endpoint and subscription key. This method is intended only for users who use a non-standard service endpoint or parameters. Note: Please use your LanguageUnderstanding subscription key in case you want to use the Intent recognizer. Note: The query parameters specified in the endpoint URL are not changed, even if they are set by any other APIs. For example, if language is defined in the uri as query parameter "language=de-DE", and also set by SpeechConfig.speechRecognitionLanguage = "en-US", the language setting in uri takes precedence, and the effective language is "de-DE". Only the parameters that are not specified in the endpoint URL can be set by other APIs. Note: To use authorization token with fromEndpoint, pass an empty string to the subscriptionKey in the fromEndpoint method, and then set authorizationToken="token" on the created SpeechConfig instance to use the authorization token.

fromHost(URL, string)

Creates an instance of the speech config with specified host and subscription key. This method is intended only for users who use a non-default service host. Standard resource path will be assumed. For services with a non-standard resource path or no path at all, use fromEndpoint instead. Note: Query parameters are not allowed in the host URI and must be set by other APIs. Note: To use an authorization token with fromHost, use fromHost(URL), and then set the AuthorizationToken property on the created SpeechConfig instance. Note: Added in version 1.9.0.

fromSubscription(string, string)

Static instance of SpeechConfig returned by passing subscriptionKey and service region. Note: Please use your LanguageUnderstanding subscription key in case you want to use the Intent recognizer.

getProperty(string, string)

Returns the current value of an arbitrary property.

requestWordLevelTimestamps()
setProfanity(ProfanityOption)
setProperty(string, string)

Sets an arbitrary property.

setProxy(string, number)

Sets the proxy configuration. Only relevant in Node.js environments. Added in version 1.4.0.

setProxy(string, number, string, string)

Sets the proxy configuration. Only relevant in Node.js environments. Added in version 1.4.0.

setServiceProperty(string, string, ServicePropertyChannel)

Property Details

authorizationToken

Gets the authorization token. Gets/Sets the authorization token. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token.

string authorizationToken

Property Value

string

endpointId

Gets the endpoint ID of a customized speech model that is used for speech recognition. Gets/Sets the endpoint ID of a customized speech model that is used for speech recognition.

string endpointId

Property Value

string

The endpoint ID

outputFormat

Gets speech recognition output format (simple or detailed). Note: This output format is for speech recognition result, use [SpeechConfig.speechSynthesisOutputFormat] to get synthesized audio output format. Gets/Sets speech recognition output format (simple or detailed). Note: This output format is for speech recognition result, use [SpeechConfig.speechSynthesisOutputFormat] to set synthesized audio output format.

OutputFormat outputFormat

Property Value

Returns the output format.

region

string region

Property Value

string

The region set on the config.

speechRecognitionLanguage

Returns the configured language. Gets/Sets the input language.

string speechRecognitionLanguage

Property Value

string

speechSynthesisLanguage

Gets the language of the speech synthesizer. Sets the language of the speech synthesizer.

string speechSynthesisLanguage

Property Value

string

Returns the speech synthesis language. Added in version 1.11.0.

speechSynthesisOutputFormat

Gets the speech synthesis output format. Sets the speech synthesis output format (e.g. Riff16Khz16BitMonoPcm).

SpeechSynthesisOutputFormat speechSynthesisOutputFormat

Property Value

Returns the speech synthesis output format Added in version 1.11.0.

speechSynthesisVoiceName

Gets the voice of the speech synthesizer. Sets the voice of the speech synthesizer. (see available voices).

string speechSynthesisVoiceName

Property Value

string

Returns the speech synthesis voice. Added in version 1.11.0.

subscriptionKey

string subscriptionKey

Property Value

string

The subscription key set on the config.

Method Details

close()

Closes the configuration.

function close()

enableAudioLogging()

function enableAudioLogging()

enableDictation()

function enableDictation()

fromAuthorizationToken(string, string)

Creates an instance of the speech factory with specified initial authorization token and region. Note: The caller needs to ensure that the authorization token is valid. Before the authorization token expires, the caller needs to refresh it by calling this setter with a new valid token. Note: Please use a token derived from your LanguageUnderstanding subscription key in case you want to use the Intent recognizer. As configuration values are copied when creating a new recognizer, the new token value will not apply to recognizers that have already been created. For recognizers that have been created before, you need to set authorization token of the corresponding recognizer to refresh the token. Otherwise, the recognizers will encounter errors during recognition.

static function fromAuthorizationToken(authorizationToken: string, region: string)

Parameters

authorizationToken

string

The initial authorization token.

region

string

The region name (see the region page).

Returns

A speech factory instance.

fromEndpoint(URL, string)

Creates an instance of the speech config with specified endpoint and subscription key. This method is intended only for users who use a non-standard service endpoint or parameters. Note: Please use your LanguageUnderstanding subscription key in case you want to use the Intent recognizer. Note: The query parameters specified in the endpoint URL are not changed, even if they are set by any other APIs. For example, if language is defined in the uri as query parameter "language=de-DE", and also set by SpeechConfig.speechRecognitionLanguage = "en-US", the language setting in uri takes precedence, and the effective language is "de-DE". Only the parameters that are not specified in the endpoint URL can be set by other APIs. Note: To use authorization token with fromEndpoint, pass an empty string to the subscriptionKey in the fromEndpoint method, and then set authorizationToken="token" on the created SpeechConfig instance to use the authorization token.

static function fromEndpoint(endpoint: URL, subscriptionKey?: string)

Parameters

endpoint

URL

The service endpoint to connect to.

subscriptionKey

string

The subscription key. If a subscription key is not specified, an authorization token must be set.

Returns

A speech factory instance.

fromHost(URL, string)

Creates an instance of the speech config with specified host and subscription key. This method is intended only for users who use a non-default service host. Standard resource path will be assumed. For services with a non-standard resource path or no path at all, use fromEndpoint instead. Note: Query parameters are not allowed in the host URI and must be set by other APIs. Note: To use an authorization token with fromHost, use fromHost(URL), and then set the AuthorizationToken property on the created SpeechConfig instance. Note: Added in version 1.9.0.

static function fromHost(hostName: URL, subscriptionKey?: string)

Parameters

hostName

URL

subscriptionKey

string

The subscription key. If a subscription key is not specified, an authorization token must be set.

Returns

A speech factory instance.

fromSubscription(string, string)

Static instance of SpeechConfig returned by passing subscriptionKey and service region. Note: Please use your LanguageUnderstanding subscription key in case you want to use the Intent recognizer.

static function fromSubscription(subscriptionKey: string, region: string)

Parameters

subscriptionKey

string

The subscription key.

region

string

The region name (see the region page).

Returns

The speech factory

getProperty(string, string)

Returns the current value of an arbitrary property.

function getProperty(name: string, def?: string)

Parameters

name

string

The name of the property to query.

def

string

The value to return in case the property is not known.

Returns

string

The current value, or provided default, of the given property.

requestWordLevelTimestamps()

function requestWordLevelTimestamps()

setProfanity(ProfanityOption)

function setProfanity(profanity: ProfanityOption)

Parameters

profanity
ProfanityOption

setProperty(string, string)

Sets an arbitrary property.

function setProperty(name: string, value: string)

Parameters

name

string

The name of the property to set.

value

string

The new value of the property.

setProxy(string, number)

Sets the proxy configuration. Only relevant in Node.js environments. Added in version 1.4.0.

function setProxy(proxyHostName: string, proxyPort: number)

Parameters

proxyHostName

string

The host name of the proxy server.

proxyPort

number

The port number of the proxy server.

setProxy(string, number, string, string)

Sets the proxy configuration. Only relevant in Node.js environments. Added in version 1.4.0.

function setProxy(proxyHostName: string, proxyPort: number, proxyUserName: string, proxyPassword: string)

Parameters

proxyHostName

string

The host name of the proxy server, without the protocol scheme (http://)

proxyPort

number

The port number of the proxy server.

proxyUserName

string

The user name of the proxy server.

proxyPassword

string

The password of the proxy server.

setServiceProperty(string, string, ServicePropertyChannel)

function setServiceProperty(name: string, value: string, channel: ServicePropertyChannel)

Parameters

name

string

value

string