SpeechSynthesizer Class
A speech synthesizer.
- Inheritance
-
builtins.objectSpeechSynthesizer
Constructor
SpeechSynthesizer(speech_config: ~azure.cognitiveservices.speech.SpeechConfig, audio_config: ~azure.cognitiveservices.speech.audio.AudioOutputConfig | None = <azure.cognitiveservices.speech.audio.AudioOutputConfig object>, auto_detect_source_language_config: ~azure.cognitiveservices.speech.languageconfig.AutoDetectSourceLanguageConfig | None = None)
Parameters
Name | Description |
---|---|
speech_config
Required
|
The config for the speech synthesizer |
audio_config
|
The config for the audio output. This parameter is optional. If it is not provided, the default speaker device will be used for audio output. If it is None, the output audio will be dropped. None can be used for scenarios like performance test. |
auto_detect_source_language_config
|
The auto detection source language config Default value: None
|
Methods
get_voices_async |
Get the available voices, asynchronously. |
speak |
Performs synthesis on a speech synthesis request in a blocking (synchronous) mode. This method is in preview and may be subject to change in future versions. Added in version 1.37.0. |
speak_async |
Performs synthesis on a speech synthesis request in a non-blocking (asynchronous) mode. This method is in preview and may be subject to change in future versions. Added in version 1.37.0. |
speak_ssml |
Performs synthesis on ssml in a blocking (synchronous) mode. |
speak_ssml_async |
Performs synthesis on ssml in a non-blocking (asynchronous) mode. |
speak_text |
Performs synthesis on plain text in a blocking (synchronous) mode. |
speak_text_async |
Performs synthesis on plain text in a non-blocking (asynchronous) mode. |
start_speaking |
Starts synthesis on a speech synthesis request in a blocking (synchronous) mode. This method is in preview and may be subject to change in future versions. Added in version 1.37.0. |
start_speaking_ssml |
Starts synthesis on ssml in a blocking (synchronous) mode. |
start_speaking_ssml_async |
Starts synthesis on ssml in a non-blocking (asynchronous) mode. |
start_speaking_text |
Starts synthesis on plain text in a blocking (synchronous) mode. |
start_speaking_text_async |
Starts synthesis on plain text in a non-blocking (asynchronous) mode. |
stop_speaking |
Synchronously terminates ongoing synthesis operation. This method will stop playback and clear unread data in PullAudioOutputStream. |
stop_speaking_async |
Asynchronously terminates ongoing synthesis operation. This method will stop playback and clear unread data in PullAudioOutputStream. |
get_voices_async
Get the available voices, asynchronously.
get_voices_async(locale: str = '') -> ResultFuture
Parameters
Name | Description |
---|---|
locale
Required
|
Specify the locale of voices, in BCP-47 format; or leave it empty to get all available voices. |
Returns
Type | Description |
---|---|
A task representing the asynchronous operation that gets the voices. |
speak
Performs synthesis on a speech synthesis request in a blocking (synchronous) mode.
This method is in preview and may be subject to change in future versions. Added in version 1.37.0.
speak(request: SpeechSynthesisRequest) -> SpeechSynthesisResult
Parameters
Name | Description |
---|---|
request
Required
|
The speech synthesis request. |
Returns
Type | Description |
---|---|
A SpeechSynthesisResult. |
speak_async
Performs synthesis on a speech synthesis request in a non-blocking (asynchronous) mode.
This method is in preview and may be subject to change in future versions. Added in version 1.37.0.
speak_async(request: SpeechSynthesisRequest) -> ResultFuture
Parameters
Name | Description |
---|---|
request
Required
|
The speech synthesis request. |
Returns
Type | Description |
---|---|
A future with SpeechSynthesisResult. |
speak_ssml
Performs synthesis on ssml in a blocking (synchronous) mode.
speak_ssml(ssml: str) -> SpeechSynthesisResult
Parameters
Name | Description |
---|---|
ssml
Required
|
|
Returns
Type | Description |
---|---|
A SpeechSynthesisResult. |
speak_ssml_async
Performs synthesis on ssml in a non-blocking (asynchronous) mode.
speak_ssml_async(ssml: str) -> ResultFuture
Parameters
Name | Description |
---|---|
ssml
Required
|
|
Returns
Type | Description |
---|---|
A future with SpeechSynthesisResult. |
speak_text
Performs synthesis on plain text in a blocking (synchronous) mode.
speak_text(text: str) -> SpeechSynthesisResult
Parameters
Name | Description |
---|---|
text
Required
|
|
Returns
Type | Description |
---|---|
A SpeechSynthesisResult. |
speak_text_async
Performs synthesis on plain text in a non-blocking (asynchronous) mode.
speak_text_async(text: str) -> ResultFuture
Parameters
Name | Description |
---|---|
text
Required
|
|
Returns
Type | Description |
---|---|
A future with SpeechSynthesisResult. |
start_speaking
Starts synthesis on a speech synthesis request in a blocking (synchronous) mode.
This method is in preview and may be subject to change in future versions. Added in version 1.37.0.
start_speaking(request: SpeechSynthesisRequest) -> SpeechSynthesisResult
Parameters
Name | Description |
---|---|
request
Required
|
The speech synthesis request. |
Returns
Type | Description |
---|---|
A SpeechSynthesisResult. |
start_speaking_ssml
Starts synthesis on ssml in a blocking (synchronous) mode.
start_speaking_ssml(ssml: str) -> SpeechSynthesisResult
Parameters
Name | Description |
---|---|
ssml
Required
|
|
Returns
Type | Description |
---|---|
A SpeechSynthesisResult. |
start_speaking_ssml_async
Starts synthesis on ssml in a non-blocking (asynchronous) mode.
start_speaking_ssml_async(ssml: str) -> ResultFuture
Parameters
Name | Description |
---|---|
ssml
Required
|
|
Returns
Type | Description |
---|---|
A future with SpeechSynthesisResult. |
start_speaking_text
Starts synthesis on plain text in a blocking (synchronous) mode.
start_speaking_text(text: str) -> SpeechSynthesisResult
Parameters
Name | Description |
---|---|
text
Required
|
|
Returns
Type | Description |
---|---|
A SpeechSynthesisResult. |
start_speaking_text_async
Starts synthesis on plain text in a non-blocking (asynchronous) mode.
start_speaking_text_async(text: str) -> ResultFuture
Parameters
Name | Description |
---|---|
text
Required
|
|
Returns
Type | Description |
---|---|
A future with SpeechSynthesisResult. |
stop_speaking
Synchronously terminates ongoing synthesis operation. This method will stop playback and clear unread data in PullAudioOutputStream.
stop_speaking() -> None
stop_speaking_async
Asynchronously terminates ongoing synthesis operation. This method will stop playback and clear unread data in PullAudioOutputStream.
stop_speaking_async() -> ResultFuture
Returns
Type | Description |
---|---|
A future that is fulfilled once synthesis has been stopped. |
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. Otherwise, the synthesizer will encounter errors while speech synthesis.
bookmark_reached
Signal for events indicating a bookmark is reached.
Callbacks connected to this signal are called with a SpeechSynthesisBookmarkEventArgs instance as the single argument.
Note
Added in version 1.16.0.
properties
A collection of properties and their values defined for this SpeechSynthesizer.
synthesis_canceled
Signal for events indicating synthesis has been canceled.
Callbacks connected to this signal are called with a SpeechSynthesisEventArgs instance as the single argument.
synthesis_completed
Signal for events indicating synthesis has completed.
Callbacks connected to this signal are called with a SpeechSynthesisEventArgs instance as the single argument.
synthesis_started
Signal for events indicating synthesis has started.
Callbacks connected to this signal are called with a SpeechSynthesisEventArgs instance as the single argument.
synthesis_word_boundary
Signal for events indicating a word boundary.
Callbacks connected to this signal are called with a SpeechSynthesisWordBoundaryEventArgs instance as the single argument.
synthesizing
Signal for events indicating synthesis is ongoing.
Callbacks connected to this signal are called with a SpeechSynthesisEventArgs instance as the single argument.
viseme_received
Signal for events indicating a viseme is received.
Callbacks connected to this signal are called with a SpeechSynthesisVisemeEventArgs instance as the single argument.
Note
Added in version 1.16.0.
Azure SDK for Python