Commit 1620e1e7 authored by 赵啸非's avatar 赵啸非

修改音频识别结果

parent 06c2aa48
......@@ -97,8 +97,9 @@ public class ApiSendMsgController {
String jsonStr = "";
try {
if (file == null || file.getSize() == 0L) throw new AppException("文件为空!");
if (!"pcm".equalsIgnoreCase(FileUtil.getSuffix(file.getOriginalFilename())))
throw new AppException("只支持pcm文件!");
if (!"pcm".equalsIgnoreCase(FileUtil.getSuffix(file.getOriginalFilename()))&&
!"mp3".equalsIgnoreCase(FileUtil.getSuffix(file.getOriginalFilename())))
throw new AppException("只支持pcm或mp3文件!");
//if (file.getOriginalFilename())
String filePath = uploadService.saveFileUpload(file, prePath, null);
filePath = uploadService.getFilePath(filePath);
......@@ -124,12 +125,13 @@ public class ApiSendMsgController {
// model.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonStr = JSONObject.toJSONString(model);
} catch (AppException e) {
log.error("异常", e);
model.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
model.put(KEY_RESULT_MSG, e.getMessage());
jsonStr = JSONObject.toJSONString(model);
} catch (Exception e) {
log.error("异常", e);
model.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
model.put(KEY_RESULT_MSG, "文件上传失败");
jsonStr = JSONObject.toJSONString(model);
......
package com.mortals.xhx.common.pdu;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class Audio{
@JSONField(name = "sample_rate")
private int sampleRate;
private int channels;
private String audio;
private String encoding;
@JSONField(name = "bit_depth")
private int bitDepth;
private int seq;
private int status;
}
\ No newline at end of file
package com.mortals.xhx.common.pdu;
import lombok.Data;
@Data
public class AudioRoot{
private Payload payload;
private Parameter parameter;
private Header header;
}
\ No newline at end of file
package com.mortals.xhx.common.pdu;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
@Data
public class Header{
@JSONField(name = "app_id")
private String appId;
private int status;
}
\ No newline at end of file
package com.mortals.xhx.common.pdu;
import lombok.Data;
@Data
public class Iat{
private Result result;
private int vinfo;
private String domain;
private int eos;
private String language;
private String accent;
}
\ No newline at end of file
package com.mortals.xhx.common.pdu;
import lombok.Data;
@Data
public class Parameter{
private Iat iat;
}
\ No newline at end of file
package com.mortals.xhx.common.pdu;
import lombok.Data;
@Data
public class Payload{
private Audio audio;
}
\ No newline at end of file
package com.mortals.xhx.common.pdu;
import lombok.Data;
@Data
public class Result{
private String compress;
private String format;
private String encoding;
}
\ No newline at end of file
......@@ -38,10 +38,20 @@ Content-Disposition: form-data; name="file"; filename="file.zip"
POST {{baseUrl}}/audio/upload
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="test.mp3"
< ./test.mp3
--WebAppBoundary--
###上传音频文件1
POST {{baseUrl}}/audio/upload
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="test.pcm"
< ./test.pcm
< ./test1.pcm
--WebAppBoundary--
###测试链接数据库
......
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