SpeechConfig Class
Class that defines configurations for speech / intent recognition and speech synthesis.
The configuration can be initialized in different ways:
from subscription: pass a subscription key and a region
from endpoint: pass an endpoint. Subscription key or authorization token are optional.
from host: pass a host address. Subscription key or authorization token are optional.
from authorization token: pass an authorization token and a region
- Inheritance
-
builtins.objectSpeechConfig
Constructor
SpeechConfig(subscription: str | None = None, region: str | None = None, endpoint: str | None = None, host: str | None = None, auth_token: str | None = None, speech_recognition_language: str | None = None)
Parameters
Name | Description |
---|---|
subscription
|
The subscription key. Default value: None
|
region
|
The region name (see the region page). Default value: None
|
endpoint
|
The service endpoint to connect to. Default value: None
|
host
|
The service host to connect to. Standard resource path will be assumed. Format is "protocol://host:port" where ":port" is optional. Default value: None
|
auth_token
|
The authorization token. Default value: None
|
speech_recognition_language
|
The input language to the speech recognition. The language is specified in BCP-47 format. Default value: None
|
Methods
enable_audio_logging |
Enables audio logging in service. 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). Note Added in version 1.5.0. |
enable_dictation |
Enables dictation. Only supported in speech continuous recognition. Note Added in version 1.5.0. |
get_property |
Get a property by id. |
get_property_by_name |
Get a property by name. |
request_word_level_timestamps |
Includes word level timestamps in response result. Note Added in version 1.5.0. |
set_profanity |
Set the profanity option. Note Added in version 1.5.0. |
set_properties |
Set multiple properties by id. |
set_properties_by_name |
Set multiple properties by name. |
set_property |
Set a property by id. |
set_property_by_name |
Set a property by name. |
set_proxy |
Set proxy information. Note Proxy functionality is not available on macOS. This function will have no effect on this platform. |
set_service_property |
Sets a property value that will be passed to service using the specified channel. Note Added in version 1.5.0. |
set_speech_synthesis_output_format |
Set speech synthesis output audio format. |
enable_audio_logging
Enables audio logging in service. 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).
Note
Added in version 1.5.0.
enable_audio_logging()
enable_dictation
Enables dictation. Only supported in speech continuous recognition.
Note
Added in version 1.5.0.
enable_dictation()
get_property
Get a property by id.
get_property(property_id: PropertyId) -> str
Parameters
Name | Description |
---|---|
property_id
Required
|
The id of the property to be retrieved. |
Returns
Type | Description |
---|---|
The value of the property. |
get_property_by_name
Get a property by name.
get_property_by_name(property_name: str) -> str
Parameters
Name | Description |
---|---|
property_name
Required
|
The name of the property to be retrieved. |
Returns
Type | Description |
---|---|
The value of the property. |
request_word_level_timestamps
Includes word level timestamps in response result.
Note
Added in version 1.5.0.
request_word_level_timestamps()
set_profanity
Set the profanity option.
Note
Added in version 1.5.0.
set_profanity(profanity_option: ProfanityOption) -> None
Parameters
Name | Description |
---|---|
profanity_option
Required
|
The profanity level to set. |
set_properties
Set multiple properties by id.
set_properties(properties: Dict[PropertyId, str])
Parameters
Name | Description |
---|---|
properties
Required
|
A dict mapping property ids to the values to be set. |
set_properties_by_name
Set multiple properties by name.
set_properties_by_name(properties: Dict[str, str])
Parameters
Name | Description |
---|---|
properties
Required
|
A dict mapping property ids to the values to be set. |
set_property
Set a property by id.
set_property(property_id: PropertyId, value: str)
Parameters
Name | Description |
---|---|
property_id
Required
|
The id of the property to be set. |
value
Required
|
The value to be set for the property. |
set_property_by_name
Set a property by name.
set_property_by_name(property_name: str, value: str)
Parameters
Name | Description |
---|---|
property_name
Required
|
The name of the property to be set. |
value
Required
|
The value to be set for the property. |
set_proxy
Set proxy information.
Note
Proxy functionality is not available on macOS. This function will have no effect on
this platform.
set_proxy(hostname: str, port: int, username: str | None = None, password: str | None = None)
Parameters
Name | Description |
---|---|
hostname
Required
|
The host name of the proxy server. Do not add protocol information (http) to the hostname. |
port
Required
|
The port number of the proxy server. |
username
|
The user name of the proxy server. Default value: None
|
password
|
The password of the proxy server. Default value: None
|
set_service_property
Sets a property value that will be passed to service using the specified channel.
Note
Added in version 1.5.0.
set_service_property(name: str, value: str, channel: ServicePropertyChannel)
Parameters
Name | Description |
---|---|
name
Required
|
The property name. |
value
Required
|
The property value. |
channel
Required
|
The channel used to pass the specified property to service. |
set_speech_synthesis_output_format
Set speech synthesis output audio format.
set_speech_synthesis_output_format(format_id: SpeechSynthesisOutputFormat)
Parameters
Name | Description |
---|---|
format_id
Required
|
The audio format id, e.g. Riff16Khz16BitMonoPcm. |
Attributes
authorization_token
The authorization token that will be used for connecting 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.
endpoint_id
The endpoint id.
output_format
The output format (simple or detailed) of the speech recognition result.
region
The region key that was used to create the Recognizer.
speech_recognition_language
The name of spoken language to be recognized in BCP-47 format.
speech_synthesis_language
Get speech synthesis language.
speech_synthesis_output_format_string
Get speech synthesis output audio format string.
speech_synthesis_voice_name
Get speech synthesis voice name.
subscription_key
The subscription key that was used to create the Recognizer.
Azure SDK for Python