class Dialog::D ialogServiceConnector

class Dialog::DialogServiceConnector
  : public std::enable_shared_from_this< DialogServiceConnector >
  : public Utils::NonCopyable
  : public Utils::NonMovable

用于连接 DirectLineSpeech 或 CustomCommands 的对象。

此类型的对象通过 FromConfig 工厂方法创建。

成员

已确认

语法:public EventSignal< const SpeechRecognitionEventArgs & > Recognized;

包含语音识别结果的事件的信号。

识别

语法:public EventSignal< const SpeechRecognitionEventArgs & > Recognizing;

包含中间识别结果的事件的信号。

SessionStarted

语法:public EventSignal< const SessionEventArgs & > SessionStarted;

指示侦听会话的开始的信号。

SessionStopped

语法:public EventSignal< const SessionEventArgs & > SessionStopped;

指示侦听会话结束的信号。

SpeechStartDetected

语法:public EventSignal< const RecognitionEventArgs & > SpeechStartDetected;

指示当前短语中第一次检测语音数据的信号。

SpeechEndDetected

语法:public EventSignal< const RecognitionEventArgs & > SpeechEndDetected;

指示检测到当前短语语音数据的末尾的信号。

取消

语法:public EventSignal< const SpeechRecognitionCanceledEventArgs & > Canceled;

与取消交互相关的事件的信号。 该事件指示原因是直接取消还是错误。

ActivityReceived

语法:public EventSignal< const ActivityReceivedEventArgs & > ActivityReceived;

指示从后端接收活动。

TurnStatusReceived

语法:public EventSignal< const TurnStatusReceivedEventArgs & > TurnStatusReceived;

指示从后端接收轮次状态更新。

性能

语法:public PropertyCollection & Properties;

为此 DialogServiceConnector 定义的属性及其值的集合。

~DialogServiceConnector

语法:public inline virtual ~DialogServiceConnector ( );

销毁实例。

ConnectAsync

语法:public inline std::future< void > ConnectAsync ( );

与后端连接。

退货

启动连接的异步作。

DisconnectAsync

语法:public inline std::future< void > DisconnectAsync ( );

断开与后端的连接。

退货

启动断开连接的异步作。

SendActivityAsync

语法:public inline std::future< std::string > SendActivityAsync ( const std::string & activity );

将活动发送到支持对话框。

参数

  • 要发送 activity 活动

退货

启动作的异步作。

StartKeywordRecognitionAsync

语法:public inline std::future< void > StartKeywordRecognitionAsync ( std::shared_ptr< KeywordRecognitionModel > model );

启动关键字识别。

参数

  • model 指定要使用的关键字模型。

退货

启动作的异步作。

StopKeywordRecognitionAsync

语法:public inline std::future< void > StopKeywordRecognitionAsync ( );

停止关键字识别。

退货

启动作的异步作。

ListenOnceAsync

语法:public inline std::future< std::shared_ptr< SpeechRecognitionResult > > ListenOnceAsync ( );

启动将在第一个陈述后终止的侦听会话。

退货

启动作的异步作。

StopListeningAsync

语法:public inline std::future< void > StopListeningAsync ( );

请求活动侦听作立即完成,中断任何正在进行的说话,并提供一个反映到目前为止捕获的任何音频数据的结果。

退货

表示停止活动侦听会话的异步作的任务。

SetAuthorizationToken

语法:public inline void SetAuthorizationToken ( const std::string & token );

设置将用于连接到服务的授权令牌。 注意:调用方需要确保授权令牌有效。 在授权令牌过期之前,调用方需要使用新的有效令牌调用此 setter 来刷新它。 否则,连接器在作过程中将遇到错误。

参数

  • token 授权令牌。

GetAuthorizationToken

语法:public inline std::string GetAuthorizationToken ( );

获取授权令牌。

退货

授权令牌

SetSpeechActivityTemplate

语法:public inline void SetSpeechActivityTemplate ( const std::string & activityTemplate );

设置一个 JSON 模板,该模板将提供给下一个会话的语音服务。 该服务将尝试将此模板合并到发送到对话后端的所有活动中,无论是由具有 SendActivityAsync 的客户端发起还是由服务生成,语音转文本结果的情况也一样。

参数

  • activityTemplate 活动有效负载(作为 JSON 字符串)合并到所有适用的活动消息中。

GetSpeechActivityTemplate

语法:public inline std::string GetSpeechActivityTemplate ( );

获取将提供给下一个会话的语音服务的 JSON 模板。 该服务将尝试将此模板合并到发送到对话后端的所有活动中,无论是由具有 SendActivityAsync 的客户端发起还是由服务生成,语音转文本结果的情况也一样。

退货

当前将用于后续请求的 JSON 活动模板。

FromConfig

语法:public inline static std::shared_ptr< DialogServiceConnector > FromConfig ( std::shared_ptr< DialogServiceConfig > connectorConfig , std::shared_ptr< Audio::AudioConfig > audioConfig );

DialogServiceConfigAudio::AudioConfig创建对话服务连接器。 用户应使用此函数创建对话框服务连接器。

参数

  • connectorConfig 对话框服务配置。

  • audioConfig 音频配置。

退货

创建的对话框服务连接器的共享智能指针。

auto audioConfig = [Audio::AudioConfig::FromDefaultMicrophoneInput](audio-audioconfig.md#fromdefaultmicrophoneinput)();
auto config = [CustomCommandsConfig::FromAuthorizationToken](dialog-customcommandsconfig.md#fromauthorizationtoken)("my_app_id","my_auth_token", "my_region");
auto connector = [DialogServiceConnector::FromConfig](#fromconfig)(config, audioConfig);

在谈到 dialogServiceConfig 我们指的是继承自它的类之一。 要使用的特定类取决于所使用的对话框后端: