56 lines
1.3 KiB
Plaintext
56 lines
1.3 KiB
Plaintext
|
||
export type CallbackData={
|
||
modelPath:string
|
||
}
|
||
|
||
|
||
export type CallbackType={
|
||
code:number,
|
||
data:CallbackData
|
||
}
|
||
|
||
/**
|
||
* modelPath 模型解压后的地址,当已存在该路径时使用,即已解压过模型
|
||
* zipModelPath 模型地址,例如/static/vosk-model-small-cn-0.22.zip
|
||
* voskType 初始化类型,1-实时语音识别 2-本地wav语音文件识别(单声道 PCM)
|
||
*/
|
||
export type InitModelData={
|
||
modelPath?:string|null,
|
||
zipModelPath:string,
|
||
voskType?:string|null
|
||
}
|
||
export type ResultData={
|
||
text:string,
|
||
errorMsg?:string|null
|
||
}
|
||
export type RedultType={
|
||
code:number,
|
||
data:ResultData
|
||
}
|
||
|
||
export type DownloadBackInfo={
|
||
code:number,
|
||
filePath:string
|
||
}
|
||
|
||
export type SpeechResultCallback=(val:RedultType)=>void
|
||
export type DownloadCallback=(val:DownloadBackInfo)=>void
|
||
|
||
export type DownloadOpt={
|
||
modelUrl:string,
|
||
savePath:string
|
||
}
|
||
/**
|
||
* 实例方法
|
||
* initVoskModel 初始化模型
|
||
* startSpeechVoice 开始语音识别
|
||
* stopSpeechVoice 停止识别
|
||
* getSpeechResult 获取结果
|
||
*/
|
||
export type UseVoskOption={
|
||
initVoskModel:(opt:InitModelData,cb:(val:CallbackType)=>void)=>void,
|
||
startSpeechVoice:(cb:SpeechResultCallback)=>void,
|
||
stopSpeechVoice:()=>void,
|
||
getSpeechResult:()=>RedultType,
|
||
downloadModel:(url:string,cb:DownloadCallback)=>void,
|
||
} |