Commit 4089b544 authored by 赵啸非's avatar 赵啸非

添加音频识别

parent e401e397
package com.mortals.xhx.busiz.web;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.exception.AppException;
......@@ -91,11 +93,20 @@ public class ApiSendMsgController {
public SseEmitter doFileUpload(MultipartFile file, @RequestParam(value = "prePath", defaultValue = "") String prePath) {
Map<String, Object> model = new HashMap<>();
String jsonStr = "";
SseEmitter emitter = new SseEmitter(30000L);
SseEmitter emitter = new SseEmitter(10 * 60 * 1000L);
try {
if( file == null||file.getSize()==0L) throw new AppException("文件为空!");
if(!"pcm".equalsIgnoreCase(FileUtil.getSuffix(file.getOriginalFilename()))) throw new AppException("只支持pcm文件!");
//if (file.getOriginalFilename())
String filePath = uploadService.saveFileUpload(file, prePath, null);
filePath = uploadService.getFilePath(filePath);
log.info("filePath==>" + filePath);
IatModelMulUtil iatModelMulUtil = new IatModelMulUtil(filePath, appid, emitter);
......
......@@ -182,12 +182,6 @@ public class IatModelMulUtil extends WebSocketListener {
} catch (IOException e) {
log.error("发送异常==》{}", e.getMessage());
}
//emitter.n
// emitter.next(rsp);
// System.out.print(cw.w);
}
}
}
......@@ -201,6 +195,7 @@ public class IatModelMulUtil extends WebSocketListener {
// System.out.println("最终识别结果 ==》" + decodeRes); // 按照规则替换与追加出最终识别结果
log.info("本次识别sid ==》" + jsonParse.header.sid);
emitter.complete();
log.info("emitter 关闭");
webSocket.close(1000, "");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment