SpeechTranslationConfig Class
Class that defines configurations for translation with speech input.
The configuration can be initialized in different ways:
from subscription: pass a subscription key and a region
from endpoint: pass a subscription key and an endpoint
from host: pass a subscription key and a host address
from authorization token: pass an authorization token and a region
- Inheritance
-
SpeechTranslationConfig
Constructor
SpeechTranslationConfig(subscription: str | None = None, region: str | None = None, endpoint: str | None = None, host: str | None = None, auth_token: str | None = None, target_languages: Iterable[str] = [], voice_name: str = '', speech_recognition_language: str = '')
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
Required
|
The input language to the speech recognition. The language is specified in BCP-47 format. |
target_languages
|
The target languages for translation. Default value: []
|
voice_name
Required
|
The voice to use for synthesized output. |
Methods
add_target_language |
Add language to the list of target languages for translation. |
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. |
remove_target_language |
Remove language from the list of target languages for translation. Note Added in version 1.7.0. |
request_word_level_timestamps |
Includes word level timestamps in response result. Note Added in version 1.5.0. |
set_custom_model_category_id |
Sets a Category Id that will be passed to service. Category Id is used to find the custom model. |
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. |
add_target_language
Add language to the list of target languages for translation.
add_target_language(language: str)
Parameters
Name | Description |
---|---|
language
Required
|
The language code to add. |
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. |
remove_target_language
Remove language from the list of target languages for translation.
Note
Added in version 1.7.0.
remove_target_language(language: str)
Parameters
Name | Description |
---|---|
language
Required
|
The language code to remove. |
request_word_level_timestamps
Includes word level timestamps in response result.
Note
Added in version 1.5.0.
request_word_level_timestamps()
set_custom_model_category_id
Sets a Category Id that will be passed to service. Category Id is used to find the custom model.
set_custom_model_category_id(categoryid: str)
Parameters
Name | Description |
---|---|
categoryid
Required
|
the category Id. |
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.
target_languages
The target languages for translation.
voice_name
The voice to use for synthesized output.
Azure SDK for Python