guoyu/fronted_uniapp/uni_modules/xwq-speech-to-text/utssdk/interface.uts

56 lines
1.3 KiB
Plaintext
Raw Normal View History

2025-12-03 18:58:36 +08:00
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
2025-12-03 18:58:36 +08:00
}
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,
}