public class ASREngine
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ASREngine.AsrppType |
static interface |
ASREngine.Callback |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
TAG |
static int |
TIMEOUT_ASR |
Modifier | Constructor and Description |
---|---|
protected |
ASREngine() |
protected |
ASREngine(java.lang.String lBridgeAddr) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
取消此次识别
|
protected void |
destroy() |
void |
disablePunctuation()
关闭识别支持标点符号的特性
|
boolean |
disableVad()
设置取消VAD检测接口
|
void |
enablePunctuation()
打开识别支持标点符号的特性
|
boolean |
enableVad()
设置使用VAD检测接口
|
void |
enableVolume(boolean enable)
设置时时回传音量大小, 默认为true
|
java.lang.String |
getAsrModel()
获取当前使用的云端识别的模型
|
java.lang.String |
getAsrppWithPcm(byte[] pcm,
ASREngine.AsrppType... types)
获取音频对应的性别/年龄/情绪
|
java.lang.String |
getGenderWithPcm(byte[] pcm)
Deprecated.
|
static ASREngine |
getInstance() |
static ASREngine |
getInstance(java.lang.String lBridgeAddr) |
static ASREngine |
getInstanceSnapshot()
获取 ASREngine 实例快照
|
java.lang.String |
getVadDump()
获取vad dump info
|
long |
getVadPauseTime()
获取VAD后端停顿时间的接口
|
long |
getVadTimeout()
获取VAD前端超时时间的接口
|
java.lang.String |
getVadVersion()
获取vad版本:lua版本 - c版本 接口
|
void |
killVadTimeoutInFullDuplex()
在全双工模式下,跳过Vad的超时检测
|
void |
setReversedChannel(boolean isReversedChannel)
动态设置录音通道是否反转
|
boolean |
setVadPauseTime(long millis)
设置VAD后端停顿时间的接口
|
boolean |
setVadTimeout(long millis)
设置VAD前端超时时间的接口
|
void |
startListening(ASREngine.Callback callback)
主动开始识别
|
void |
stopListening()
主动结束识别
|
void |
updateAsrModel(java.lang.String asrModel)
更新云端识别的模型名字,
在调用完该接口后,下一次对话开始时生效,并一直用该模型,除非客户端再调用该接口设置为其他的模型
|
public static final java.lang.String TAG
public static final int TIMEOUT_ASR
protected ASREngine()
protected ASREngine(java.lang.String lBridgeAddr)
public static ASREngine getInstance()
public static ASREngine getInstance(java.lang.String lBridgeAddr)
public static ASREngine getInstanceSnapshot()
public void startListening(ASREngine.Callback callback) throws DDSNotInitCompleteException
调用后直接进入识别,识别结果通过ASREngine.Callback
返回。
若当前正在对话中,会先结束当前对话,再开启识别。
若产品开启VAD,用户结束说话之后会自动结束识别,无须调用stopListening()
callback
- 识别结果通的回调接口。识别结束或取消后,将被清除。DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic boolean setVadTimeout(long millis) throws DDSNotInitCompleteException
若VAD启动,一直未检测到用户说话,超过一定时间,发出sys.vad.timeout消息,结束录音。 设置成功后,vad再次启动生效
millis
- 前端超时时间,单位为毫秒。默认值为8000毫秒。DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic void killVadTimeoutInFullDuplex() throws DDSNotInitCompleteException
全双工模式下, VAD启动后调用此接口会清除VAD的超时机制, 人声检测超时机制交由服务端来判断 此接口只在全双工模式下生效, 并在当前对话时生效, 开启新的对话后此状态会恢复为默认的vad超时检测
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic long getVadTimeout() throws DDSNotInitCompleteException
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic boolean setVadPauseTime(long millis) throws DDSNotInitCompleteException
若VAD在用户说话时停顿超过一定的时间,则认为用户已经说完,发出sys.vad.end消息,结束录音。
millis
- 后端停顿时间,单位为毫秒。默认值为500毫秒。DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic long getVadPauseTime() throws DDSNotInitCompleteException
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic java.lang.String getVadVersion() throws DDSNotInitCompleteException
DDSNotInitCompleteException
public java.lang.String getVadDump() throws DDSNotInitCompleteException
DDSNotInitCompleteException
public boolean enableVad() throws DDSNotInitCompleteException
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic boolean disableVad() throws DDSNotInitCompleteException
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic void stopListening() throws DDSNotInitCompleteException
调用后,最终识别结果会通过ASREngine.Callback.finalResults(String)
回调,然后ASREngine.Callback
将会被清除。
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic void cancel() throws DDSNotInitCompleteException
调用后,ASREngine.Callback
将会被清除,并不再触发任何回调。
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic void enablePunctuation() throws DDSNotInitCompleteException
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic void disablePunctuation() throws DDSNotInitCompleteException
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic void updateAsrModel(java.lang.String asrModel) throws DDSNotInitCompleteException
asrModel
- 云端识别的模型名字,有aihome, airobot等,
默认为dui控制台配置的模型资源,
如果填null,则表示清除之前本地配置的模型名,之后会使用dui控制台配置的模型资源DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic java.lang.String getAsrModel() throws DDSNotInitCompleteException
DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exception@Deprecated public java.lang.String getGenderWithPcm(byte[] pcm) throws DDSNotInitCompleteException
pcm
- 一次性输入识别的单路音频(建议输入1.2~1.5秒的有效音频,有效音频不得少于0.6秒)DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic java.lang.String getAsrppWithPcm(byte[] pcm, ASREngine.AsrppType... types) throws DDSNotInitCompleteException
pcm
- 一次性输入识别的单路音频(建议输入1.2~1.5秒的有效音频,有效音频不得少于0.6秒)DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic void enableVolume(boolean enable) throws DDSNotInitCompleteException
enable
- true/false true:支持时时回传音量 false:关闭时时回传音量DDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionpublic void setReversedChannel(boolean isReversedChannel) throws DDSNotInitCompleteException
isReversedChannel
- true or falseDDSNotInitCompleteException
- 如果DDS没有初始化完成,会抛出exceptionprotected void destroy()