您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.
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: typing.Union[str, NoneType] = None, region: typing.Union[str, NoneType] = None, endpoint: typing.Union[str, NoneType] = None, host: typing.Union[str, NoneType] = None, auth_token: typing.Union[str, NoneType] = None, speech_recognition_language: typing.Union[str, NoneType] = None)
Parameters
- subscription
The subscription key.
- region
The region name (see the region page).
- endpoint
The service endpoint to connect to.
- host
The service host to connect to. Standard resource path will be assumed. Format is "protocol://host:port" where ":port" is optional.
- auth_token
The authorization token.
- speech_recognition_language
The input language to the speech recognition. The language is specified in BCP-47 format.
Methods
enable_audio_logging |
Enables audio logging in service. 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.
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: azure.cognitiveservices.speech.PropertyId) -> str
Parameters
- property_id
The id of the property to be retrieved.
Returns
The value of the property.
get_property_by_name
Get a property by name.
get_property_by_name(property_name: str) -> str
Parameters
- property_name
The name of the property to be retrieved.
Returns
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: azure.cognitiveservices.speech.ProfanityOption) -> str
Parameters
- profanity_option
The profanity level to set.
set_properties
Set multiple properties by id.
set_properties(properties: typing.Dict[azure.cognitiveservices.speech.PropertyId, str])
Parameters
- properties
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: typing.Dict[str, str])
Parameters
- properties
A dict mapping property ids to the values to be set.
set_property
Set a property by id.
set_property(property_id: azure.cognitiveservices.speech.PropertyId, value: str)
Parameters
- property_id
The id of the property to be set.
- value
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
- property_name
The name of the property to be set.
- value
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: str, username: str, password: str)
Parameters
- hostname
The host name of the proxy server. Do not add protocol information (http) to the hostname.
- port
The port number of the proxy server.
- username
The user name of the proxy server.
- password
The password of the proxy server.
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: azure.cognitiveservices.speech.ServicePropertyChannel)
Parameters
- name
The property name.
- value
The property value.
- channel
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: azure.cognitiveservices.speech.SpeechSynthesisOutputFormat)
Parameters
- format_id
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.