class SpeechSynthesizer
class SpeechSynthesizer
: public std::enable_shared_from_this< SpeechSynthesizer >
Class for speech synthesizer. Updated in version 1.14.0.
Members
Properties
Syntax: public PropertyCollection & Properties;
A collection of properties and their values defined for this SpeechSynthesizer.
SynthesisStarted
Syntax: public EventSignal< const SpeechSynthesisEventArgs & > SynthesisStarted;
The event signals that a speech synthesis result is received when the synthesis just started.
Synthesizing
Syntax: public EventSignal< const SpeechSynthesisEventArgs & > Synthesizing;
The event signals that a speech synthesis result is received while the synthesis is on going.
SynthesisCompleted
Syntax: public EventSignal< const SpeechSynthesisEventArgs & > SynthesisCompleted;
The event signals that a speech synthesis result is received when the synthesis completed.
SynthesisCanceled
Syntax: public EventSignal< const SpeechSynthesisEventArgs & > SynthesisCanceled;
The event signals that a speech synthesis result is received when the synthesis is canceled.
WordBoundary
Syntax: public EventSignal< const SpeechSynthesisWordBoundaryEventArgs & > WordBoundary;
The event signals that a speech synthesis word boundary is received while the synthesis is on going. Added in version 1.7.0.
VisemeReceived
Syntax: public EventSignal< const SpeechSynthesisVisemeEventArgs & > VisemeReceived;
The event signals that a speech synthesis viseme event is received while the synthesis is on going. Added in version 1.16.0.
BookmarkReached
Syntax: public EventSignal< const SpeechSynthesisBookmarkEventArgs & > BookmarkReached;
The event signals that a speech synthesis bookmark is reached while the synthesis is on going. Added in version 1.16.0.
SpeakText
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > SpeakText ( const std::string & text );
Execute the speech synthesis on plain text, synchronously.
Parameters
text
The plain text for synthesis.
Returns
A smart pointer wrapping a speech synthesis result.
SpeakText
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > SpeakText ( const std::wstring & text );
Execute the speech synthesis on plain text, synchronously. Added in 1.9.0.
Parameters
text
The plain text for synthesis.
Returns
A smart pointer wrapping a speech synthesis result.
SpeakSsml
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > SpeakSsml ( const std::string & ssml );
Execute the speech synthesis on SSML, synchronously.
Parameters
ssml
The SSML for synthesis.
Returns
A smart pointer wrapping a speech synthesis result.
SpeakSsml
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > SpeakSsml ( const std::wstring & ssml );
Execute the speech synthesis on SSML, synchronously. Added in version 1.9.0.
Parameters
ssml
The SSML for synthesis.
Returns
A smart pointer wrapping a speech synthesis result.
Speak
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > Speak ( const std::shared_ptr< SpeechSynthesisRequest > & request );
Execute the speech synthesis on request, synchronously. This API could be used to synthesize speech from an input text stream, to reduce latency for text generation scenarios. Note: the feature is in preview and is subject to change. Added in version 1.37.0.
Parameters
request
The synthesis request.
Returns
A smart pointer wrapping a speech synthesis result.
SpeakTextAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakTextAsync ( const std::string & text );
Execute the speech synthesis on plain text, asynchronously.
Parameters
text
The plain text for synthesis.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
SpeakTextAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakTextAsync ( const std::wstring & text );
Execute the speech synthesis on plain text, asynchronously. Added in version 1.9.0.
Parameters
text
The plain text for synthesis.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
SpeakSsmlAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakSsmlAsync ( const std::string & ssml );
Execute the speech synthesis on SSML, asynchronously.
Parameters
ssml
The SSML for synthesis.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
SpeakSsmlAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakSsmlAsync ( const std::wstring & ssml );
Execute the speech synthesis on SSML, asynchronously. Added in version 1.9.0.
Parameters
ssml
The SSML for synthesis.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
SpeakAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakAsync ( const std::shared_ptr< SpeechSynthesisRequest > & request );
Execute the speech synthesis on on request, synchronously. This API could be used to synthesize speech from an input text stream, to reduce latency for text generation scenarios. Note: the feature is in preview and is subject to change. Added in version 1.37.0.
Parameters
request
The synthesis request.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
StartSpeakingText
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > StartSpeakingText ( const std::string & text );
Start the speech synthesis on plain text, synchronously.
Parameters
text
The plain text for synthesis.
Returns
A smart pointer wrapping a speech synthesis result.
StartSpeakingText
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > StartSpeakingText ( const std::wstring & text );
Start the speech synthesis on plain text, synchronously. Added in version 1.9.0.
Parameters
text
The plain text for synthesis.
Returns
A smart pointer wrapping a speech synthesis result.
StartSpeakingSsml
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > StartSpeakingSsml ( const std::string & ssml );
Start the speech synthesis on SSML, synchronously.
Parameters
ssml
The SSML for synthesis.
Returns
A smart pointer wrapping a speech synthesis result.
StartSpeakingSsml
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > StartSpeakingSsml ( const std::wstring & ssml );
Start the speech synthesis on SSML, synchronously. Added in version 1.9.0.
Parameters
ssml
The SSML for synthesis.
Returns
A smart pointer wrapping a speech synthesis result.
StartSpeaking
Syntax: public inline std::shared_ptr< SpeechSynthesisResult > StartSpeaking ( const std::shared_ptr< SpeechSynthesisRequest > & request );
Start the speech synthesis on on request, synchronously. This API could be used to synthesize speech from an input text stream, to reduce latency for text generation scenarios. Note: the feature is in preview and is subject to change. Added in version 1.37.0.
Parameters
request
The synthesis request.
Returns
A smart pointer wrapping a speech synthesis result.
StartSpeakingTextAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > StartSpeakingTextAsync ( const std::string & text );
Start the speech synthesis on plain text, asynchronously.
Parameters
text
The plain text for synthesis.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
StartSpeakingTextAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > StartSpeakingTextAsync ( const std::wstring & text );
Start the speech synthesis on plain text, asynchronously. Added in version 1.9.0.
Parameters
text
The plain text for synthesis.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
StartSpeakingSsmlAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > StartSpeakingSsmlAsync ( const std::string & ssml );
Start the speech synthesis on SSML, asynchronously.
Parameters
ssml
The SSML for synthesis.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
StartSpeakingSsmlAsync
Syntax: public inline std::future< std::shared_ptr< SpeechSynthesisResult > > StartSpeakingSsmlAsync ( const std::wstring & ssml );
Start the speech synthesis on SSML, asynchronously. Added in version 1.9.0.
Parameters
ssml
The SSML for synthesis.
Returns
An asynchronous operation representing the synthesis. It returns a value of SpeechSynthesisResult as result.
StopSpeakingAsync
Syntax: public inline std::future< void > StopSpeakingAsync ( );
Stop the speech synthesis, asynchronously. Added in version 1.14.0.
Returns
An empty future.
GetVoicesAsync
Syntax: public inline std::future< std::shared_ptr< SynthesisVoicesResult > > GetVoicesAsync ( const std::string & locale );
Get the available voices, asynchronously. Added in version 1.16.0.
Parameters
locale
Specify the locale of voices, in BCP-47 format; or leave it empty to get all available voices.
Returns
An asynchronous operation representing the voices list. It returns a value of SynthesisVoicesResult as result.
SetAuthorizationToken
Syntax: public inline void SetAuthorizationToken ( const std::string & token );
Sets 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. Added in version 1.7.0.
Parameters
token
The authorization token.
GetAuthorizationToken
Syntax: public inline std::string GetAuthorizationToken ( ) const;
Gets the authorization token. Added in version 1.7.0.
Returns
Authorization token
~SpeechSynthesizer
Syntax: public inline ~SpeechSynthesizer ( );
Destructor.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::nullptr_t );
Create a speech synthesizer from a speech config.
Parameters
speechconfig
Speech configuration.
Returns
A smart pointer wrapped speech synthesizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechconfig , std::nullptr_t );
Create a speech synthesizer from an embedded speech config. Added in version 1.19.0.
Parameters
speechconfig
Embedded speech configuration.
Returns
A smart pointer wrapped speech synthesizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< HybridSpeechConfig > speechconfig , std::nullptr_t );
Create a speech synthesizer from a hybrid speech config.
Parameters
speechconfig
Hybrid speech configuration.
Returns
A smart pointer wrapped speech synthesizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::shared_ptr< Audio::AudioConfig > audioconfig );
Create a speech synthesizer from a speech config and audio config.
Parameters
speechconfig
Speech configuration.audioconfig
Audio configuration.
Returns
A smart pointer wrapped speech synthesizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechconfig , std::shared_ptr< Audio::AudioConfig > audioconfig );
Create a speech synthesizer from an embedded speech config and audio config. Added in version 1.19.0.
Parameters
speechconfig
Embedded speech configuration.audioconfig
Audio configuration.
Returns
A smart pointer wrapped speech synthesizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< HybridSpeechConfig > speechconfig , std::shared_ptr< Audio::AudioConfig > audioconfig );
Create a speech synthesizer from a hybrid speech config and audio config.
Parameters
speechconfig
Hybrid speech configuration.audioconfig
Audio configuration.
Returns
A smart pointer wrapped speech synthesizer pointer.
FromConfig
Syntax: public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::shared_ptr< AutoDetectSourceLanguageConfig > autoDetectSourceLangConfig , std::shared_ptr< Audio::AudioConfig > audioconfig );
Create a speech synthesizer from a speech config, auto detection source language config and audio config Added in 1.13.0.
Parameters
speechconfig
Speech configuration.autoDetectSourceLangConfig
Auto detection source language config.audioconfig
Audio configuration.
Returns
A smart pointer wrapped speech synthesizer pointer.