语音交互服务 SIS-一句话识别(websocket版):初始化Client
初始化Client
初始化SasrWsClient,其中参数包含AuthInfo,SisHttpConfig,SasrWsResponseListener,SasrWsConnProcessListener。
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
AuthInfo |
是 |
Object |
鉴权信息类。 |
SisHttpConfig |
是 |
Object |
连接时网络的配置类。 |
SasrWsResponseListener |
是 |
Object |
webSocket回调过程中,业务逻辑的Listener。 |
SasrWsConnProcessListener |
否 |
Object |
webSocket生命周期的Listener。 |
其中AuthInfo和SisHttpConfig的参数如下表所示
参数名称 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
ak |
是 |
String |
用户的ak,可参考AK/SK认证。 |
sk |
是 |
String |
用户的sk,可参考AK/SK认证。 |
serviceRegion |
是 |
String |
区域,如cn-north-4,参考终端节点。 |
projectId |
是 |
String |
项目ID,同region一一对应,参考获取项目ID。 |
serviceEndPoint |
否 |
String |
终端节点,参考地区和终端节点。 |
参数名称 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
connectionTimeout |
否 |
Integer |
连接超时,默认10000,单位ms。 |
readTimeout |
否 |
Integer |
读取超时,默认10000,单位ms。 |
websocketWaitTimeout |
否 |
Integer |
webSocket返回数据时等待时间,默认20000,单位毫秒。 |
ProxyHostInfo |
否 |
ProxyHostInfo |
代理类。 |
参数名称 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
userName |
否 |
String |
代理用户名(例:test)。 |
passWord |
否 |
String |
代理密码(例:test)。 |
hostName |
否 |
String |
代理地址(例:“proxy.huaweicloud.com”)。 |
port |
否 |
int |
代理端口号(例:8080)。 |
函数 |
描述 |
---|---|
void onExceededAudio(); |
识别时长超过一分钟时,响应,后续录入音频不在识别。 |
void onResponseError(AsrResponse response); |
识别过程中出现异常,调用。 |
void onResponseEnd(AsrResponse response); |
识别结束时回调。 |
void onResponseBegin(AsrResponse response); |
识别开始时回调。 |
void onResponseMessage(AsrResponse message); |
返回识别的结果。 |
函数 |
描述 |
---|---|
void onTranscriptionConnect() |
webSocket连接建立后回调。 |
void onTranscriptionClose(); |
webSocket连接关闭后回调 |
void onTranscriptionFail(AsrResponse var1); |
webSocket长连接连接失败是回调。 |