Class SpeechSynthesizer
class SpeechSynthesizer
: public std::enable_shared_from_this< SpeechSynthesizer >
语音合成器类。 已在版本 1.14.0 中更新。
成员
性能
语法:public PropertyCollection & Properties;
为此 SpeechSynthesizer 定义的属性及其值的集合。
SynthesisStarted
语法:public EventSignal< const SpeechSynthesisEventArgs & > SynthesisStarted;
事件指示在刚开始合成时收到语音合成结果。
合成
语法:public EventSignal< const SpeechSynthesisEventArgs & > Synthesizing;
事件指示在进行合成时接收语音合成结果。
SynthesisCompleted
语法:public EventSignal< const SpeechSynthesisEventArgs & > SynthesisCompleted;
事件指示在合成完成后接收语音合成结果。
SynthesisCanceled
语法:public EventSignal< const SpeechSynthesisEventArgs & > SynthesisCanceled;
事件指示取消合成时收到语音合成结果。
WordBoundary
语法:public EventSignal< const SpeechSynthesisWordBoundaryEventArgs & > WordBoundary;
该事件指示在进行合成时接收语音合成字边界。 在版本 1.7.0 中添加。
VisemeReceived
语法:public EventSignal< const SpeechSynthesisVisemeEventArgs & > VisemeReceived;
该事件指示在进行合成时接收语音合成视体事件。 已在版本 1.16.0 中添加。
BookmarkReached
语法:public EventSignal< const SpeechSynthesisBookmarkEventArgs & > BookmarkReached;
事件指示在合成正在进行时到达语音合成书签。 已在版本 1.16.0 中添加。
SpeakText
语法:public inline std::shared_ptr< SpeechSynthesisResult > SpeakText ( const std::string & text );
在纯文本上同步执行语音合成。
参数
-
text
用于合成的纯文本。
退货
智能指针包装语音合成结果。
SpeakText
语法:public inline std::shared_ptr< SpeechSynthesisResult > SpeakText ( const std::wstring & text );
在纯文本上同步执行语音合成。 在 1.9.0 中添加。
参数
-
text
用于合成的纯文本。
退货
智能指针包装语音合成结果。
SpeakSsml
语法:public inline std::shared_ptr< SpeechSynthesisResult > SpeakSsml ( const std::string & ssml );
在 SSML 上同步执行语音合成。
参数
-
ssml
用于合成的 SSML。
退货
智能指针包装语音合成结果。
SpeakSsml
语法:public inline std::shared_ptr< SpeechSynthesisResult > SpeakSsml ( const std::wstring & ssml );
在 SSML 上同步执行语音合成。 在版本 1.9.0 中添加。
参数
-
ssml
用于合成的 SSML。
退货
智能指针包装语音合成结果。
Speak
语法:public inline std::shared_ptr< SpeechSynthesisResult > Speak ( const std::shared_ptr< SpeechSynthesisRequest > & request );
同步对请求执行语音合成。 此 API 可用于从输入文本流合成语音,以减少文本生成方案的延迟。 注意:该功能处于预览状态,可能会更改。 在版本 1.37.0 中添加。
参数
-
request
合成请求。
退货
智能指针包装语音合成结果。
SpeakTextAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakTextAsync ( const std::string & text );
异步对纯文本执行语音合成。
参数
-
text
用于合成的纯文本。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
SpeakTextAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakTextAsync ( const std::wstring & text );
异步对纯文本执行语音合成。 在版本 1.9.0 中添加。
参数
-
text
用于合成的纯文本。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
SpeakSsmlAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakSsmlAsync ( const std::string & ssml );
异步在 SSML 上执行语音合成。
参数
-
ssml
用于合成的 SSML。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
SpeakSsmlAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakSsmlAsync ( const std::wstring & ssml );
异步在 SSML 上执行语音合成。 在版本 1.9.0 中添加。
参数
-
ssml
用于合成的 SSML。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
SpeakAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > SpeakAsync ( const std::shared_ptr< SpeechSynthesisRequest > & request );
在请求上同步执行语音合成。 此 API 可用于从输入文本流合成语音,以减少文本生成方案的延迟。 注意:该功能处于预览状态,可能会更改。 在版本 1.37.0 中添加。
参数
-
request
合成请求。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
StartSpeakingText
语法:public inline std::shared_ptr< SpeechSynthesisResult > StartSpeakingText ( const std::string & text );
同步启动纯文本的语音合成。
参数
-
text
用于合成的纯文本。
退货
智能指针包装语音合成结果。
StartSpeakingText
语法:public inline std::shared_ptr< SpeechSynthesisResult > StartSpeakingText ( const std::wstring & text );
同步启动纯文本的语音合成。 在版本 1.9.0 中添加。
参数
-
text
用于合成的纯文本。
退货
智能指针包装语音合成结果。
StartSpeakingSsml
语法:public inline std::shared_ptr< SpeechSynthesisResult > StartSpeakingSsml ( const std::string & ssml );
同步启动 SSML 上的语音合成。
参数
-
ssml
用于合成的 SSML。
退货
智能指针包装语音合成结果。
StartSpeakingSsml
语法:public inline std::shared_ptr< SpeechSynthesisResult > StartSpeakingSsml ( const std::wstring & ssml );
同步启动 SSML 上的语音合成。 在版本 1.9.0 中添加。
参数
-
ssml
用于合成的 SSML。
退货
智能指针包装语音合成结果。
StartSpeaking
语法:public inline std::shared_ptr< SpeechSynthesisResult > StartSpeaking ( const std::shared_ptr< SpeechSynthesisRequest > & request );
按请求同步启动语音合成。 此 API 可用于从输入文本流合成语音,以减少文本生成方案的延迟。 注意:该功能处于预览状态,可能会更改。 在版本 1.37.0 中添加。
参数
-
request
合成请求。
退货
智能指针包装语音合成结果。
StartSpeakingTextAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > StartSpeakingTextAsync ( const std::string & text );
异步启动纯文本的语音合成。
参数
-
text
用于合成的纯文本。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
StartSpeakingTextAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > StartSpeakingTextAsync ( const std::wstring & text );
异步启动纯文本的语音合成。 在版本 1.9.0 中添加。
参数
-
text
用于合成的纯文本。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
StartSpeakingSsmlAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > StartSpeakingSsmlAsync ( const std::string & ssml );
异步启动 SSML 上的语音合成。
参数
-
ssml
用于合成的 SSML。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
StartSpeakingSsmlAsync
语法:public inline std::future< std::shared_ptr< SpeechSynthesisResult > > StartSpeakingSsmlAsync ( const std::wstring & ssml );
异步启动 SSML 上的语音合成。 在版本 1.9.0 中添加。
参数
-
ssml
用于合成的 SSML。
退货
表示合成的异步作。 它返回一个结果为 SpeechSynthesisResult 的值。
StopSpeakingAsync
语法:public inline std::future< void > StopSpeakingAsync ( );
异步停止语音合成。 已在版本 1.14.0 中添加。
退货
空的未来。
GetVoicesAsync
语法:public inline std::future< std::shared_ptr< SynthesisVoicesResult > > GetVoicesAsync ( const std::string & locale );
异步获取可用语音。 已在版本 1.16.0 中添加。
参数
-
locale
以 BCP-47 格式指定语音的区域设置;或将其留空,以获取所有可用的语音。
退货
表示语音列表的异步作。 它返回 SynthesisVoicesResult 的值。
SetAuthorizationToken
语法:public inline void SetAuthorizationToken ( const std::string & token );
设置将用于连接到服务的授权令牌。 注意:调用方需要确保授权令牌有效。 在授权令牌过期之前,调用方需要使用新的有效令牌调用此 setter 来刷新它。 否则,合成器在语音合成时会遇到错误。 在版本 1.7.0 中添加。
参数
-
token
授权令牌。
GetAuthorizationToken
语法:public inline std::string GetAuthorizationToken ( ) const;
获取授权令牌。 在版本 1.7.0 中添加。
退货
授权令牌
~SpeechSynthesizer
语法:public inline ~SpeechSynthesizer ( );
析构函数。
FromConfig
语法:public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::nullptr_t );
从语音配置创建语音合成器。
参数
-
speechconfig
语音配置。
退货
智能指针包装语音合成器指针。
FromConfig
语法:public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechconfig , std::nullptr_t );
从嵌入式语音配置创建语音合成器。在版本 1.19.0 中添加。
参数
-
speechconfig
嵌入式语音配置。
退货
智能指针包装语音合成器指针。
FromConfig
语法:public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< HybridSpeechConfig > speechconfig , std::nullptr_t );
从混合语音配置创建语音合成器。
参数
-
speechconfig
混合语音配置。
退货
智能指针包装语音合成器指针。
FromConfig
语法:public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::shared_ptr< Audio::AudioConfig > audioconfig );
从语音配置和音频配置创建语音合成器。
参数
speechconfig
语音配置。audioconfig
音频配置。
退货
智能指针包装语音合成器指针。
FromConfig
语法:public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< EmbeddedSpeechConfig > speechconfig , std::shared_ptr< Audio::AudioConfig > audioconfig );
从嵌入式语音配置和音频配置创建语音合成器。在版本 1.19.0 中添加。
参数
speechconfig
嵌入式语音配置。audioconfig
音频配置。
退货
智能指针包装语音合成器指针。
FromConfig
语法:public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< HybridSpeechConfig > speechconfig , std::shared_ptr< Audio::AudioConfig > audioconfig );
从混合语音配置和音频配置创建语音合成器。
参数
speechconfig
混合语音配置。audioconfig
音频配置。
退货
智能指针包装语音合成器指针。
FromConfig
语法:public inline static std::shared_ptr< SpeechSynthesizer > FromConfig ( std::shared_ptr< SpeechConfig > speechconfig , std::shared_ptr< AutoDetectSourceLanguageConfig > autoDetectSourceLangConfig , std::shared_ptr< Audio::AudioConfig > audioconfig );
从语音配置、自动检测源语言配置和 1.13.0 中添加的音频配置创建语音合成器。
参数
speechconfig
语音配置。autoDetectSourceLangConfig
自动检测源语言配置。audioconfig
音频配置。
退货
智能指针包装语音合成器指针。