类 BaseProcessor
- java.lang.Object
-
- com.aispeech.lite.BaseProcessor
-
- 所有已实现的接口:
AIRecordListener,MessageProcess.Handle
- 直接已知子类:
AsrProcessor,CloudDmFullDuplexProcessor,CloudDmProcessor,CloudSemanticProcessor,CloudSemanticProcessor,DmaspProcessor,FaspProcessor,FespxProcessor,HotWordsProcessor,LocalAsrppProcessor,LocalAsrProcessor,LocalEchoProcessor,LocalGrammarProcessor,LocalLAsrProcessor,LocalSemanticProcessor,LocalVadProcessor,MdsProcessor,SemanticProcessor,SevcProcessor,VprintLiteProcessor,VprintProcessor,WakeupIncrementProcessor,WakeupProcessor
public abstract class BaseProcessor extends java.lang.Object implements AIRecordListener, MessageProcess.Handle
Created by yuruilong on 2017/5/15.
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classBaseProcessor.CallbackMsg类说明: 对外回调消息列表static classBaseProcessor.EngineMsg引擎内部消息static classBaseProcessor.EngineState类说明: 引擎内部状态列表classBaseProcessor.MyBarrierRunnable
-
字段概要
字段 修饰符和类型 字段 说明 protected static intDEFAULT_ONE_CHANNEL_DATA_SIZEprotected static intDEFAULT_VALID_TIME_THRESHprotected booleaninputContinuousAudio单麦、多麦唤醒feed的是短音频还是连续的长音频,用于上传唤醒音频的日志protected booleanisInitFailedprotected IAudioRecordermAIRecorderprotected AIEngineConfigmBaseConfigprotected BaseProcessor.EngineStatemCallbackStateprotected android.content.ContextmContextprotected intmCurrentDataSizeprotected intmDataSizeThreshprotected intmDumpCurrentDataSizeprotected intmDumpDataThreshprotected java.lang.ObjectmDumpLockprotected java.util.Queue<byte[]>mDumpWkpDataQueueprotected booleanmHasHalfWakeupprotected booleanmHasPreWakeupprotected booleanmIsRealWakeupprotected longmLastWakeupTimeprotected java.lang.ObjectmLockprotected java.lang.StringmMicMatrixStrprotected booleanmNeedCacheprotected booleanmNeedDumpDataprotected SpeechListenermOutListenerprotected com.aispeech.auth.AIProfilemProfileprotected com.aispeech.auth.ProfileStatemProfileStateprotected java.lang.StringmRecorderIdprotected java.lang.StringmSceneStrprotected java.lang.StringmScopeprotected BaseProcessor.EngineStatemStateprotected java.util.Queue<byte[]>mUploadCacheQueueprotected org.json.JSONObjectmWakeupJsonprotected intthreadCount
-
构造器概要
构造器 构造器 说明 BaseProcessor()
-
方法概要
所有方法 实例方法 抽象方法 具体方法 已过时的方法 修饰符和类型 方法 说明 voidcancel()protected voidcancelMaxSpeechTimeTask()protected voidcancelNoSpeechTimer()取消无语音检测定时器protected voidcancelOneShotNoSpeechTimer()voidclearObject()protected voidclearRecorderId()protected intcopyAssetsFolder(AIEngineConfig config)拷贝assets下的文件夹protected intcopyAssetsFolderMd5(AIEngineConfig config)拷贝assets下的文件夹protected intcopyAssetsFolders(AIEngineConfig config)拷贝assets目录下的多个文件夹protected intcopyAssetsRes(AIEngineConfig config)拷贝assets目录下的制定资源protected IAudioRecordercreateRecorder(AIRecordListener listener)protected IAudioRecordercreateSignalProcessingRecorder(FespxProcessor processor)创建前端信号处理录音机voidfeedData(byte[] data, int size)自定义feed音频voidforceRequestWakeupResult()intget(java.lang.String param)BaseProcessor.EngineStategetCurrentState()java.lang.StringgetHandleName()protected java.lang.StringgetRecorderId()java.lang.StringgetTag()doublegetThreshold(java.lang.String rec, LocalAsrParams params)获取 ASR 返回的阈值voidhandleMessage(BaseProcessor.EngineMsg engineMsg, android.os.Message msg)protected voidhandlerCallbackMsg(BaseProcessor.CallbackMsg callbackMsg, android.os.Message msg)需要继承类实现(因涉及较多引擎,暂不用abstract修饰,逐步按需实现)protected abstract voidhandlerInnerMsg(BaseProcessor.EngineMsg engineMsg, android.os.Message msg)需要继承类实现voidinit(SpeechListener listener, android.content.Context context, java.lang.String tag)protected booleanisAuthorized()授权状态booleanisContainsEnglish(java.lang.String rec)protected booleanisUploadEnable()voidonException(AIError aiError)注册录音回调方法,在异常发生时调用voidonPowerChanged(boolean isHighPower)大音量状态voidonRawDataReceived(long sessionId, byte[] buffer, int size)注册录音回调方法,在录音过程中,读取到部分音频数据时调用voidonRecordReleased()注册录音回调方法,在录音机资源释放后调用voidonRecordStarted(long sessionId)注册录音回调方法,在AIAudioRecorder已经启动,但是尚未读取录音数据时调用;voidonRecordStopped(long sessionId)注册录音回调方法,在录音停止后调用voidonResultDataReceived(byte[] buffer, int size)经过信号处理引擎后的单路数据voidprocessInit(int status)abstract voidprocessMaxSpeechError()abstract voidprocessNoSpeechError()voidprocessOneShotNoSpeechError()voidrelease()protected voidreleaseRecorder()已过时。protected voidremoveCallbackMsg()protected voidsendMsgToCallbackMsgQueue(BaseProcessor.CallbackMsg msg, java.lang.Object obj)protected voidsendMsgToInnerMsgQueue(BaseProcessor.EngineMsg msg, int arg1, int arg2, java.lang.Object obj)protected voidsendMsgToInnerMsgQueue(BaseProcessor.EngineMsg msg, java.lang.Object obj)向内部消息队列发送消息voidset(java.lang.String setStr)protected voidshowErrorMessage()protected voidshowErrorMessage(com.aispeech.auth.ProfileState state)protected voidstartDumpWaitingTimerTask(java.lang.String dumpPath)protected voidstartMaxSpeechTimerTask(SpeechParams params)protected voidstartNoSpeechTimer(SpeechParams params)启动无语音检测定时器protected voidstartOneShotNoSpeechTimer(SpeechParams params)protected voidstartRecorder(SpeechParams params, AIRecordListener listener)protected voidstartWakeupUploadWaitingTimerTask()voidstop()protected voidsyncRecorderId(SpeechParams asrParam, VadParams vadParams)设置recorder idprotected voidsyncRecorderId(java.lang.String id)设置recorder idprotected voidsyncRecorderId(java.lang.String recorderId, SpeechParams asrParam, VadParams vadParams)设置recorder idprotected voidsyncSessionId(java.lang.String sessionId, SpeechParams param)设置sessionIdprotected voidtrackInvalidState(java.lang.String msg)protected voidtransferState(BaseProcessor.EngineState nextState)protected voidunRegisterRecorderIfIsRecording(AIRecordListener listener)注销当前录音的回调,如果内部listener数量为空,则会销毁录音机voidupdate(AIEngineConfig updateConfig)voidupdate(java.lang.String updateStr)protected booleanupdateTrails(com.aispeech.auth.ProfileState profileState)voidupdateVocab(java.lang.String updateStr)
-
-
-
字段详细资料
-
DEFAULT_ONE_CHANNEL_DATA_SIZE
protected static final int DEFAULT_ONE_CHANNEL_DATA_SIZE
- 另请参阅:
- 常量字段值
-
DEFAULT_VALID_TIME_THRESH
protected static final int DEFAULT_VALID_TIME_THRESH
- 另请参阅:
- 常量字段值
-
mOutListener
protected SpeechListener mOutListener
-
mContext
protected android.content.Context mContext
-
mAIRecorder
protected IAudioRecorder mAIRecorder
-
isInitFailed
protected boolean isInitFailed
-
threadCount
protected int threadCount
-
mState
protected volatile BaseProcessor.EngineState mState
-
mCallbackState
protected BaseProcessor.EngineState mCallbackState
-
mBaseConfig
protected AIEngineConfig mBaseConfig
-
mRecorderId
protected java.lang.String mRecorderId
-
mUploadCacheQueue
protected java.util.Queue<byte[]> mUploadCacheQueue
-
mCurrentDataSize
protected int mCurrentDataSize
-
mDataSizeThresh
protected int mDataSizeThresh
-
mNeedCache
protected volatile boolean mNeedCache
-
mIsRealWakeup
protected volatile boolean mIsRealWakeup
-
mLock
protected java.lang.Object mLock
-
mMicMatrixStr
protected java.lang.String mMicMatrixStr
-
mSceneStr
protected java.lang.String mSceneStr
-
mHasPreWakeup
protected volatile boolean mHasPreWakeup
-
mHasHalfWakeup
protected volatile boolean mHasHalfWakeup
-
mWakeupJson
protected org.json.JSONObject mWakeupJson
-
mLastWakeupTime
protected long mLastWakeupTime
-
mScope
protected java.lang.String mScope
-
mDumpWkpDataQueue
protected java.util.Queue<byte[]> mDumpWkpDataQueue
-
mDumpCurrentDataSize
protected int mDumpCurrentDataSize
-
mDumpDataThresh
protected int mDumpDataThresh
-
mDumpLock
protected java.lang.Object mDumpLock
-
mNeedDumpData
protected boolean mNeedDumpData
-
inputContinuousAudio
protected boolean inputContinuousAudio
单麦、多麦唤醒feed的是短音频还是连续的长音频,用于上传唤醒音频的日志
-
mProfileState
protected com.aispeech.auth.ProfileState mProfileState
-
mProfile
protected com.aispeech.auth.AIProfile mProfile
-
-
方法详细资料
-
init
public void init(SpeechListener listener, android.content.Context context, java.lang.String tag)
-
update
public void update(AIEngineConfig updateConfig)
-
updateVocab
public void updateVocab(java.lang.String updateStr)
-
set
public void set(java.lang.String setStr)
-
get
public int get(java.lang.String param)
-
getRecorderId
protected java.lang.String getRecorderId()
-
clearRecorderId
protected void clearRecorderId()
-
syncRecorderId
protected void syncRecorderId(java.lang.String id)
设置recorder id- 参数:
id-
-
syncRecorderId
protected void syncRecorderId(SpeechParams asrParam, VadParams vadParams)
设置recorder id- 参数:
asrParam-vadParams-
-
syncRecorderId
protected void syncRecorderId(java.lang.String recorderId, SpeechParams asrParam, VadParams vadParams)设置recorder id- 参数:
recorderId- recorderIdasrParam-SpeechParamsvadParams-VadParams
-
syncSessionId
protected void syncSessionId(java.lang.String sessionId, SpeechParams param)设置sessionId- 参数:
sessionId- sessionIdparam-SpeechParams
-
feedData
public void feedData(byte[] data, int size)自定义feed音频- 参数:
data-size-
-
stop
public void stop()
-
cancel
public void cancel()
-
release
public void release()
-
forceRequestWakeupResult
public void forceRequestWakeupResult()
-
onRecordStarted
public void onRecordStarted(long sessionId)
从接口复制的说明:AIRecordListener注册录音回调方法,在AIAudioRecorder已经启动,但是尚未读取录音数据时调用;- 指定者:
onRecordStarted在接口中AIRecordListener
-
onRawDataReceived
public void onRawDataReceived(long sessionId, byte[] buffer, int size)从接口复制的说明:AIRecordListener注册录音回调方法,在录音过程中,读取到部分音频数据时调用- 指定者:
onRawDataReceived在接口中AIRecordListener
-
onResultDataReceived
public void onResultDataReceived(byte[] buffer, int size)从接口复制的说明:AIRecordListener经过信号处理引擎后的单路数据- 指定者:
onResultDataReceived在接口中AIRecordListener
-
onPowerChanged
public void onPowerChanged(boolean isHighPower)
从接口复制的说明:AIRecordListener大音量状态- 指定者:
onPowerChanged在接口中AIRecordListener- 参数:
isHighPower- 大音量状态
-
onRecordStopped
public void onRecordStopped(long sessionId)
从接口复制的说明:AIRecordListener注册录音回调方法,在录音停止后调用- 指定者:
onRecordStopped在接口中AIRecordListener
-
onRecordReleased
public void onRecordReleased()
从接口复制的说明:AIRecordListener注册录音回调方法,在录音机资源释放后调用- 指定者:
onRecordReleased在接口中AIRecordListener
-
onException
public void onException(AIError aiError)
从接口复制的说明:AIRecordListener注册录音回调方法,在异常发生时调用- 指定者:
onException在接口中AIRecordListener- 参数:
aiError- AIError Exception
-
getTag
public java.lang.String getTag()
- 指定者:
getTag在接口中AIRecordListener
-
clearObject
public void clearObject()
-
handlerInnerMsg
protected abstract void handlerInnerMsg(BaseProcessor.EngineMsg engineMsg, android.os.Message msg)
需要继承类实现- 参数:
engineMsg-msg-
-
handlerCallbackMsg
protected void handlerCallbackMsg(BaseProcessor.CallbackMsg callbackMsg, android.os.Message msg)
需要继承类实现(因涉及较多引擎,暂不用abstract修饰,逐步按需实现)- 参数:
callbackMsg-BaseProcessor.CallbackMsgmsg-Message
-
getHandleName
public java.lang.String getHandleName()
- 指定者:
getHandleName在接口中MessageProcess.Handle
-
handleMessage
public void handleMessage(BaseProcessor.EngineMsg engineMsg, android.os.Message msg)
- 指定者:
handleMessage在接口中MessageProcess.Handle
-
copyAssetsRes
protected int copyAssetsRes(AIEngineConfig config)
拷贝assets目录下的制定资源- 参数:
config-- 返回:
-
copyAssetsFolders
protected int copyAssetsFolders(AIEngineConfig config)
拷贝assets目录下的多个文件夹- 返回:
-
copyAssetsFolder
protected int copyAssetsFolder(AIEngineConfig config)
拷贝assets下的文件夹- 参数:
config-- 返回:
-
copyAssetsFolderMd5
protected int copyAssetsFolderMd5(AIEngineConfig config)
拷贝assets下的文件夹- 参数:
config-- 返回:
-
sendMsgToInnerMsgQueue
protected void sendMsgToInnerMsgQueue(BaseProcessor.EngineMsg msg, java.lang.Object obj)
向内部消息队列发送消息- 参数:
msg- SynthesizeMsg枚举obj- msg.obj
-
sendMsgToInnerMsgQueue
protected void sendMsgToInnerMsgQueue(BaseProcessor.EngineMsg msg, int arg1, int arg2, java.lang.Object obj)
-
sendMsgToCallbackMsgQueue
protected void sendMsgToCallbackMsgQueue(BaseProcessor.CallbackMsg msg, java.lang.Object obj)
-
removeCallbackMsg
protected void removeCallbackMsg()
-
trackInvalidState
protected void trackInvalidState(java.lang.String msg)
-
transferState
protected void transferState(BaseProcessor.EngineState nextState)
-
getCurrentState
public BaseProcessor.EngineState getCurrentState()
-
createRecorder
protected IAudioRecorder createRecorder(AIRecordListener listener)
-
createSignalProcessingRecorder
protected IAudioRecorder createSignalProcessingRecorder(FespxProcessor processor)
创建前端信号处理录音机- 返回:
-
startRecorder
protected void startRecorder(SpeechParams params, AIRecordListener listener)
-
releaseRecorder
@Deprecated protected void releaseRecorder()
已过时。销毁录音机
-
unRegisterRecorderIfIsRecording
protected void unRegisterRecorderIfIsRecording(AIRecordListener listener)
注销当前录音的回调,如果内部listener数量为空,则会销毁录音机- 参数:
listener- 回调
-
processInit
public void processInit(int status)
-
startNoSpeechTimer
protected void startNoSpeechTimer(SpeechParams params)
启动无语音检测定时器
-
cancelNoSpeechTimer
protected void cancelNoSpeechTimer()
取消无语音检测定时器
-
startMaxSpeechTimerTask
protected void startMaxSpeechTimerTask(SpeechParams params)
-
cancelMaxSpeechTimeTask
protected void cancelMaxSpeechTimeTask()
-
startDumpWaitingTimerTask
protected void startDumpWaitingTimerTask(java.lang.String dumpPath)
-
getThreshold
public double getThreshold(java.lang.String rec, LocalAsrParams params)获取 ASR 返回的阈值- 参数:
rec- 识别热词结果params- 本地识别参数- 返回:
- 热词对应的阈值大小
-
startWakeupUploadWaitingTimerTask
protected void startWakeupUploadWaitingTimerTask()
-
isUploadEnable
protected boolean isUploadEnable()
-
updateTrails
protected boolean updateTrails(com.aispeech.auth.ProfileState profileState)
-
isAuthorized
protected boolean isAuthorized()
授权状态- 返回:
- boolean
-
showErrorMessage
protected void showErrorMessage()
-
showErrorMessage
protected void showErrorMessage(com.aispeech.auth.ProfileState state)
-
update
public void update(java.lang.String updateStr)
-
processNoSpeechError
public abstract void processNoSpeechError()
-
processMaxSpeechError
public abstract void processMaxSpeechError()
-
processOneShotNoSpeechError
public void processOneShotNoSpeechError()
-
startOneShotNoSpeechTimer
protected void startOneShotNoSpeechTimer(SpeechParams params)
-
cancelOneShotNoSpeechTimer
protected void cancelOneShotNoSpeechTimer()
-
isContainsEnglish
public boolean isContainsEnglish(java.lang.String rec)
-
-