语音交互服务 SIS-语音合成(webSocket版):初始化Client

时间:2023-11-20 11:21:53

初始化Client

初始化RttsClient,其中参数包含AuthInfo和SisHttpConfig和RttsResponseListener。其中AuthInfo和SisHttpConfig的参数如表1所示。

表1 AuthInfo

参数名称

是否必选

参数类型

描述

ak

String

用户的ak,可参考AK/SK认证

sk

String

用户的sk,可参考AK/SK认证

serviceRegion

String

区域,如cn-north-4,参考终端节点

projectId

String

项目ID,同region一一对应,参考获取项目ID

serviceEndPoint

String

终端节点,参考地区和终端节点

表2 SisHttpConfig

参数名称

是否必选

参数类型

描述

connectionTimeout

Integer

连接超时,默认10000,单位ms。

readTimeout

Integer

读取超时,默认10000,单位ms。

websocketWaitTimeout

Integer

webSocket返回数据时等待时间,默认20000,单位毫秒。

ProxyHostInfo

ProxyHostInfo

代理类。

表3 ProxyHostInfo

参数名称

是否必选

参数类型

描述

userName

String

代理用户名(例:test)。

passWord

String

代理密码(例:test)。

hostName

String

代理地址(例:“proxy.huaweicloud.com”)。

port

int

代理端口号(例:8080)。

其中RttsResponseListener使用户自定义的,建立webSocket之后,接受服务端返回消息的Listener。

表4 RttsResponseListener

函数名称

作用

void onTranscriptionConnect();

webSocket建立连接后后调。

void onTranscriptionClose();

webSocket连接关闭后回调。

void onTranscriptionFail(RttsResponse response);

长连接连接失败是回调。

void onTranscriptionBegin(RttsResponse response);

开始合成音频数据时回调。

void onTranscriptionEnd(RttsResponse response);

合成音频数据结束时回调。

void onTranscriptionError(RttsResponse response);

合成音频数据过程中失败时回调。

void onTranscriptionResponse(byte[] bytes);

返回合成的二进制数据。

support.huaweicloud.com/sdkreference-sis/sis_05_0089.html