类 HttpBaseService
java.lang.Object
com.tencent.asr.service.HttpBaseService
- 直接已知子类:
HttpStreamService,SpeechHttpRecognizer
public class HttpBaseService
extends java.lang.Object
-
字段概要
字段 修饰符和类型 字段 说明 protected AsrConfigasrConfig全局配置protected AsrRequestasrRequest请求参数protected BaseEventListener<AsrResponse>baseEventListeners回调监听器protected booleancacheStatus缓存状态protected java.util.concurrent.atomic.AtomicBooleanendFlag结束标志protected longexpireTime过期时间,用于判断请求间隔是否超时protected java.util.concurrent.atomic.AtomicBooleanfinishFlagprotected HttpClientServicehttpClientServicehttpClient serviceprotected RealTimeEventListenerrealTimeEventListener用户实时结果监听器protected java.util.List<java.lang.String>requestStamps记录请求的stampprotected java.util.concurrent.ConcurrentHashMap<java.lang.String,AsrResponse>result响应结果protected java.util.concurrent.BlockingQueue<java.lang.String>resultQueue结果缓冲队列protected SpeechRecognitionListenerspeechRecognitionListener用户结果监听器protected com.tencent.asr.service.SpeechRecognitionSignServicespeechRecognitionSignService签名serviceprotected AsrRequestContentstaging用于记录链路的seq streamId endprotected java.lang.StringstreamId标示流的唯一主键protected java.util.concurrent.atomic.AtomicIntegersurplus用于判断请求是否处理完毕protected java.util.concurrent.BlockingQueue<AsrResponse>syncResponseQueue处理同步结果protected TractionManagertractionManager事务管理器 -
构造器概要
构造器 构造器 说明 HttpBaseService(java.lang.String streamId, AsrConfig config, AsrRequest request, SpeechRecognitionListener speechRecognitionListener)HttpBaseService(java.lang.String streamId, AsrConfig config, AsrRequest request, RealTimeEventListener realTimeEventListener, BaseEventListener<AsrResponse> baseEventListener)HttpBaseService -
方法概要
修饰符和类型 方法 说明 protected voidcloseClient()关闭httpClientbyte[]createBytes(byte[] data, int size)处理语音数据protected java.lang.StringdispatcherRequest(byte[] bytes, java.lang.Boolean endFlag)请求分发protected voidsend(byte[] data, boolean end)发送数据protected voidsendData(byte[] audio, java.lang.Boolean end)添加数据到缓冲队列voidstartListerResult()获取返回结果,对结果进行排序
-
字段详细资料
-
asrConfig
全局配置 -
asrRequest
请求参数 -
realTimeEventListener
用户实时结果监听器 -
speechRecognitionListener
用户结果监听器 -
streamId
protected java.lang.String streamId标示流的唯一主键 -
tractionManager
事务管理器 -
staging
用于记录链路的seq streamId end -
baseEventListeners
回调监听器 -
expireTime
protected long expireTime过期时间,用于判断请求间隔是否超时 -
cacheStatus
protected volatile boolean cacheStatus缓存状态 -
endFlag
protected volatile java.util.concurrent.atomic.AtomicBoolean endFlag结束标志 -
finishFlag
protected volatile java.util.concurrent.atomic.AtomicBoolean finishFlag -
speechRecognitionSignService
protected com.tencent.asr.service.SpeechRecognitionSignService speechRecognitionSignService签名service -
httpClientService
httpClient service -
requestStamps
protected java.util.List<java.lang.String> requestStamps记录请求的stamp -
resultQueue
protected java.util.concurrent.BlockingQueue<java.lang.String> resultQueue结果缓冲队列 -
syncResponseQueue
处理同步结果 -
result
响应结果 -
surplus
protected volatile java.util.concurrent.atomic.AtomicInteger surplus用于判断请求是否处理完毕
-
-
构造器详细资料
-
HttpBaseService
public HttpBaseService(java.lang.String streamId, AsrConfig config, AsrRequest request, RealTimeEventListener realTimeEventListener, BaseEventListener<AsrResponse> baseEventListener)HttpBaseService- 参数:
streamId- 流的唯一标示config- 配置AsrConfigrequest- 请求参数AsrRequestrealTimeEventListener- 结果回调函数RealTimeEventListenerbaseEventListener- 回调函数BaseEventListener
-
HttpBaseService
public HttpBaseService(java.lang.String streamId, AsrConfig config, AsrRequest request, SpeechRecognitionListener speechRecognitionListener)
-
-
方法详细资料
-
send
protected void send(byte[] data, boolean end)发送数据- 参数:
data- 语音数据end- 是否结束
-
dispatcherRequest
protected java.lang.String dispatcherRequest(byte[] bytes, java.lang.Boolean endFlag)请求分发- 参数:
bytes- 语音数据endFlag- 结束标志- 返回:
- 请求唯一标示stamp
-
createBytes
public byte[] createBytes(byte[] data, int size)处理语音数据- 参数:
data- 语音数据size- 语音数据大小- 返回:
- 处理后语音数据
-
startListerResult
public void startListerResult()获取返回结果,对结果进行排序 -
closeClient
protected void closeClient()关闭httpClient -
sendData
protected void sendData(byte[] audio, java.lang.Boolean end)添加数据到缓冲队列- 参数:
audio- 语音数据
-