你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

DialogServiceConnector 类

  • java.lang.Object
    • com.microsoft.cognitiveservices.speech.dialog.DialogServiceConnector

实现

java.lang.AutoCloseable

public class DialogServiceConnector
implements java.lang.AutoCloseable

定义 DialogServiceConnector 的类。 注意:必须调用 close () 才能释放对象持有的基础资源。

字段摘要

修饰符和类型 字段和描述
EventHandlerImpl<ActivityReceivedEventArgs> activityReceived

定义活动接收事件的事件处理程序。

EventHandlerImpl<SpeechRecognitionCanceledEventArgs> canceled

定义已取消事件的事件处理程序。

EventHandlerImpl<SpeechRecognitionEventArgs> recognized

定义已识别事件的事件处理程序。

EventHandlerImpl<SpeechRecognitionEventArgs> recognizing

定义识别事件的事件处理程序。

EventHandlerImpl<SessionEventArgs> sessionStarted

定义会话开始事件的事件处理程序。

EventHandlerImpl<SessionEventArgs> sessionStopped

定义会话停止事件的事件处理程序。

EventHandlerImpl<RecognitionEventArgs> speechEndDetected

定义语音结束检测事件的事件处理程序。

EventHandlerImpl<RecognitionEventArgs> speechStartDetected

定义语音启动检测事件的事件处理程序。

EventHandlerImpl<TurnStatusReceivedEventArgs> turnStatusReceived

定义轮次状态接收事件的事件处理程序。

构造函数摘要

构造函数 说明
DialogServiceConnector(DialogServiceConfig config)

使用来自默认麦克风输入的音频生成对话框服务连接器

DialogServiceConnector(DialogServiceConfig config, AudioConfig audioConfig)

生成对话框服务连接器

方法摘要

修饰符和类型 方法和描述
void close()

释放关联的资源。

java.util.concurrent.Future<java.lang.Void> connectAsync()

与服务连接。

java.util.concurrent.Future<java.lang.Void> disconnectAsync()

断开与服务的连接。

java.lang.String getAuthorizationToken()

获取用于与服务通信的授权令牌。

SafeHandle getImpl()

返回内部对话服务连接器实例。

PropertyCollection getProperties()

为此对话框服务连接器定义的属性及其值的集合。

java.util.concurrent.Future<SpeechRecognitionResult> listenOnceAsync()

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

java.util.concurrent.Future<java.lang.String> sendActivityAsync(String activity)

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

void setAuthorizationToken(String token)

设置用于与服务通信的授权令牌。

void setSpeechActivityTemplate(String activityTemplate)

设置将为下一个会话提供给语音服务的 JSON 模板。

java.util.concurrent.Future<java.lang.Void> startKeywordRecognitionAsync(KeywordRecognitionModel model)

启动关键字 (keyword) 识别。

java.util.concurrent.Future<java.lang.Void> stopKeywordRecognitionAsync()

停止关键字 (keyword) 识别。

java.util.concurrent.Future<java.lang.Void> stopListeningAsync()

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

方法继承自 java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

字段详细信息

activityReceived

public EventHandlerImpl activityReceived

定义活动接收事件的事件处理程序。

canceled

public EventHandlerImpl canceled

定义已取消事件的事件处理程序。

recognized

public EventHandlerImpl recognized

定义已识别事件的事件处理程序。

recognizing

public EventHandlerImpl recognizing

定义识别事件的事件处理程序。

sessionStarted

public EventHandlerImpl sessionStarted

定义会话开始事件的事件处理程序。

sessionStopped

public EventHandlerImpl sessionStopped

定义会话停止事件的事件处理程序。

speechEndDetected

public EventHandlerImpl speechEndDetected

定义语音结束检测事件的事件处理程序。

speechStartDetected

public EventHandlerImpl speechStartDetected

定义语音启动检测事件的事件处理程序。

turnStatusReceived

public EventHandlerImpl turnStatusReceived

定义轮次状态接收事件的事件处理程序。

构造函数详细信息

DialogServiceConnector

public DialogServiceConnector(DialogServiceConfig config)

使用来自默认麦克风输入的音频生成 DialogServiceConnector

Parameters:

config - 对话框服务连接器配置。

DialogServiceConnector

public DialogServiceConnector(DialogServiceConfig config, AudioConfig audioConfig)

生成 DialogServiceConnector

Parameters:

config - 对话框服务连接器配置。
audioConfig - 与识别器关联的可选音频输入配置

方法详细信息

close

public void close()

释放关联的资源。 注意:必须调用 close () 才能释放对象持有的基础资源。

connectAsync

public Future connectAsync()

与服务连接。

Returns:

表示连接到服务的异步操作的任务。

disconnectAsync

public Future disconnectAsync()

断开与服务的连接。

Returns:

表示与服务断开连接的异步操作的任务。

getAuthorizationToken

public String getAuthorizationToken()

获取用于与服务通信的授权令牌。

Returns:

授权令牌。

getImpl

public SafeHandle getImpl()

返回内部对话服务连接器实例。

Returns:

内部对话服务连接器实例

getProperties

public PropertyCollection getProperties()

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

Returns:

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

listenOnceAsync

public Future listenOnceAsync()

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

Returns:

表示启动一次侦听会话的异步操作的任务。

sendActivityAsync

public Future sendActivityAsync(String activity)

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

Parameters:

activity - 要发送的活动。

Returns:

表示将活动发送到支持对话框的异步操作的任务。

setAuthorizationToken

public void setAuthorizationToken(String token)

设置用于与服务通信的授权令牌。 注意:调用方需要确保授权令牌有效。 在授权令牌过期之前,调用方需要使用新的有效令牌调用此资源库来刷新它。 否则,识别器将在识别过程中遇到错误。

Parameters:

token - 授权令牌。

setSpeechActivityTemplate

public void setSpeechActivityTemplate(String activityTemplate)

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

Parameters:

activityTemplate - 要合并到生成的活动消息中的 JSON 有效负载。

startKeywordRecognitionAsync

public Future startKeywordRecognitionAsync(KeywordRecognitionModel model)

启动关键字 (keyword) 识别。

Parameters:

model - 指定要识别关键字 (keyword) 的关键字 (keyword) 识别模型。

Returns:

表示启动关键字 (keyword) 识别的异步操作的任务。

stopKeywordRecognitionAsync

public Future stopKeywordRecognitionAsync()

停止关键字 (keyword) 识别。

Returns:

表示停止关键字 (keyword) 识别的异步操作的任务。

stopListeningAsync

public Future stopListeningAsync()

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

Returns:

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

适用于