class SpeechConfig

Class that defines configurations for speech / intent recognition, or speech synthesis.

Members

EmbeddedSpeechConfig

Syntax: public friend EmbeddedSpeechConfig;

HybridSpeechConfig

Syntax: public friend HybridSpeechConfig;

operator SPXSPEECHCONFIGHANDLE

Syntax: public inline explicit operator SPXSPEECHCONFIGHANDLE ( ) const;

Internal operator used to get underlying handle value.

Returns

A handle.

SetSpeechRecognitionLanguage

Syntax: public inline void SetSpeechRecognitionLanguage ( const std::string & lang );

Set the input language to the speech recognizer.

Parameters

  • lang Specifies the name of spoken language to be recognized in BCP-47 format.

GetSpeechRecognitionLanguage

Syntax: public inline std::string GetSpeechRecognitionLanguage ( ) const;

Gets the input language to the speech recognition. The language is specified in BCP-47 format.

Returns

The speech recognition language.

SetSpeechSynthesisLanguage

Syntax: public inline void SetSpeechSynthesisLanguage ( const std::string & lang );

Sets the language of the speech synthesizer. Added in version 1.4.0.

Parameters

  • lang Specifies the name of language (e.g. en-US)

GetSpeechSynthesisLanguage

Syntax: public inline std::string GetSpeechSynthesisLanguage ( ) const;

Gets the language of the speech synthesizer. Added in version 1.4.0.

Returns

The speech synthesis language.

SetSpeechSynthesisVoiceName

Syntax: public inline void SetSpeechSynthesisVoiceName ( const std::string & voiceName );

Set the voice of the speech synthesizer. Added in version 1.4.0.

Parameters

  • voiceName Specifies the name of voice

GetSpeechSynthesisVoiceName

Syntax: public inline std::string GetSpeechSynthesisVoiceName ( ) const;

Gets the voice of the speech synthesizer. Added in version 1.4.0.

Returns

The speech synthesis voice name.

SetSpeechSynthesisOutputFormat

Syntax: public inline void SetSpeechSynthesisOutputFormat ( SpeechSynthesisOutputFormat formatId );

Sets the speech synthesis output format (e.g. Riff16Khz16BitMonoPcm). Added in version 1.4.0.

Parameters

  • formatId Specifies the output format ID

GetSpeechSynthesisOutputFormat

Syntax: public inline std::string GetSpeechSynthesisOutputFormat ( ) const;

Gets the speech synthesis output format. Added in version 1.4.0.

Returns

The speech synthesis output format.

SetEndpointId

Syntax: public inline void SetEndpointId ( const std::string & endpointId );

Sets the endpoint ID of Custom Speech or Custom Voice.

Parameters

  • endpointId Endpoint ID.

GetEndpointId

Syntax: public inline std::string GetEndpointId ( ) const;

Gets the endpoint ID of Custom Speech or Custom Voice.

Returns

Endpoint ID.

SetAuthorizationToken

Syntax: public inline void SetAuthorizationToken ( const std::string & token );

Sets the authorization token to connect to the service. 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. 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.

Parameters

  • token The authorization token.

GetAuthorizationToken

Syntax: public inline std::string GetAuthorizationToken ( ) const;

Gets the authorization token to connect to the service.

Returns

The authorization token.

GetSubscriptionKey

Syntax: public inline std::string GetSubscriptionKey ( ) const;

Gets the subscription key that is used to create Speech Recognizer or Intent Recognizer or Translation Recognizer or Speech Synthesizer.

Returns

The subscription key.

GetRegion

Syntax: public inline std::string GetRegion ( ) const;

Gets the region key that used to create Speech Recognizer or Intent Recognizer or Translation Recognizer or speech Synthesizer.

Returns

Region.

GetOutputFormat

Syntax: public inline OutputFormat GetOutputFormat ( ) const;

Gets speech recognition output format (simple or detailed). Note: This output format is for speech recognition result, use SpeechConfig::GetSpeechSynthesisOutputFormat to get synthesized audio output format.

Returns

Speech recognition output format.

SetOutputFormat

Syntax: public inline void SetOutputFormat ( OutputFormat format );

Sets speech recognition output format (simple or detailed). Note: This output format is for speech recognition result, use SpeechConfig::SetSpeechSynthesisOutputFormat to set synthesized audio output format.

Parameters

  • format Speech recognition output format

SetProfanity

Syntax: public inline void SetProfanity ( ProfanityOption profanity );

Sets profanity option. Added in version 1.5.0.

Parameters

  • profanity Profanity option value.

EnableAudioLogging

Syntax: public inline void EnableAudioLogging ( );

Enables audio logging in service. Added in version 1.5.0.

Audio and content logs are stored either in Microsoft-owned storage, or in your own storage account linked to your Cognitive Services subscription (Bring Your Own Storage (BYOS) enabled Speech resource).

RequestWordLevelTimestamps

Syntax: public inline void RequestWordLevelTimestamps ( );

Includes word-level timestamps in response result. Added in version 1.5.0.

EnableDictation

Syntax: public inline void EnableDictation ( );

Enables dictation mode. Only supported in speech continuous recognition. Added in version 1.5.0.

SetProxy

Syntax: public inline void SetProxy ( const std::string & proxyHostName , uint32_t proxyPort , const std::string & proxyUserName , const std::string & proxyPassword );

Sets proxy configuration Added in version 1.1.0.

Note: Proxy functionality is not available on macOS. This function will have no effect on this platform.

Parameters

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

  • proxyPort The port number of the proxy server

  • proxyUserName The user name of the proxy server

  • proxyPassword The password of the proxy server

SetProperty

Syntax: public inline void SetProperty ( const std::string & name , const std::string & value );

Sets a property value by name.

Parameters

  • name The property name.

  • value The property value.

GetProperty

Syntax: public inline std::string GetProperty ( const std::string & name ) const;

Gets a property value by name.

Parameters

  • name The parameter name.

Returns

The property value.

GetProperty

Syntax: public inline std::string GetProperty ( PropertyId id ) const;

Gets a property value by ID.

Parameters

  • id The parameter id.

Returns

The property value.

SetProperty

Syntax: public inline void SetProperty ( PropertyId id , const std::string & value );

Sets a property value by ID.

Parameters

  • id The property id.

  • value The property value.

SetServiceProperty

Syntax: public inline void SetServiceProperty ( const std::string & name , const std::string & value , ServicePropertyChannel channel );

Sets a property value that will be passed to service using the specified channel. Added in version 1.5.0.

Parameters

  • name The property name.

  • value The property value.

  • channel The channel used to pass the specified property to service.

~SpeechConfig

Syntax: public inline virtual ~SpeechConfig ( );

Destructs the object.

FromSubscription

Syntax: public inline static std::shared_ptr< SpeechConfig > FromSubscription ( const std::string & subscription , const std::string & region );

Creates an instance of the speech config with specified subscription key and region.

Parameters

  • subscription The subscription key.

  • region The region name (see the region page).

Returns

A shared pointer to the new speech config instance.

FromAuthorizationToken

Syntax: public inline static std::shared_ptr< SpeechConfig > FromAuthorizationToken ( const std::string & authToken , const std::string & region );

Creates an instance of the speech config with specified 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. 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.

Parameters

  • authToken The authorization token.

  • region The region name (see the region page).

Returns

A shared pointer to the new speech config instance.

FromEndpoint

Syntax: public inline static std::shared_ptr< SpeechConfig > FromEndpoint ( const std::string & endpoint , const std::string & subscription );

Creates an instance of the speech config with specified endpoint and subscription. This method is intended only for users who use a non-standard service endpoint. Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. For example, if the recognition language is defined in URI as query parameter "language=de-DE", and also set by SetSpeechRecognitionLanguage("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 URI can be set by other APIs. Note: To use an authorization token with FromEndpoint, use FromEndpoint(const SPXSTRING&), and then call SetAuthorizationToken() on the created SpeechConfig instance.

Parameters

  • endpoint The service endpoint to connect to.

  • subscription The subscription key.

Returns

A shared pointer to the new speech config instance.

FromEndpoint

Syntax: public inline static std::shared_ptr< SpeechConfig > FromEndpoint ( const std::string & endpoint );

Creates an instance of SpeechConfig with specified endpoint. This method is intended only for users who use a non-standard service endpoint. Note: The query parameters specified in the endpoint URI are not changed, even if they are set by any other APIs. Whether a specific query parameter is supported or not, depends on the endpoint and scenario. For example, if the recognition language is defined in URI as query parameter "language=de-DE", and also set by SetSpeechRecognitionLanguage("en-US"), the language setting in URI takes precedence, and the effective language is "de-DE". The example only applies when the endpoint and scenario combination supports language as a query parameter. Only the parameters that are not specified in the endpoint URI can be set by other APIs. Note: If the endpoint requires a subscription key for authentication, use FromEndpoint(const SPXSTRING&, const SPXSTRING&) to pass the subscription key as parameter. To use an authorization token with FromEndpoint, use this method to create a SpeechConfig instance, and then call SetAuthorizationToken() on the created SpeechConfig instance. Note: Added in version 1.5.0.

Parameters

  • endpoint The service endpoint URI to connect to.

Returns

A shared pointer to the new speech config instance.

FromHost

Syntax: public inline static std::shared_ptr< SpeechConfig > FromHost ( const std::string & host , const std::string & subscription );

Creates an instance of the speech config with specified host and subscription. 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(const SPXSTRING&), and then call SetAuthorizationToken() on the created SpeechConfig instance. Note: Added in version 1.8.0.

Parameters

  • host The service host to connect to. Format is "protocol://host:port" where ":port" is optional.

  • subscription The subscription key.

Returns

A shared pointer to the new speech config instance.

FromHost

Syntax: public inline static std::shared_ptr< SpeechConfig > FromHost ( const std::string & host );

Creates an instance of SpeechConfig with specified host. 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: If the host requires a subscription key for authentication, use FromHost(const SPXSTRING&, const SPXSTRING&) to pass the subscription key as parameter. To use an authorization token with FromHost, use this method to create a SpeechConfig instance, and then call SetAuthorizationToken() on the created SpeechConfig instance. Note: Added in version 1.8.0.

Parameters

  • host The service host URI to connect to. Format is "protocol://host:port" where ":port" is optional.

Returns

A shared pointer to the new speech config instance.