guoyu/Test/yuyin/uni_modules/xwq-speech-to-text/utssdk/interface.uts
2025-12-03 18:58:36 +08:00

55 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}
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,
}