packagecom.example.combat.asrutils;importcom.alibaba.fastjson.JSON;importcom.alibaba.fastjson.JSONObject;importcom.example.combat.config.constant.ContentTypeEnum;importcom.example.combat.config.constant.HttpMethodEnum;importcom.example.combat.config.constant.SignMenodEnum;import com.example.combat.asrutils.param.*;importcom.example.combat.afsutils.HttpUtil;importcom.example.combat.afsutils.SignUtils;importlombok.extern.slf4j.Slf4j;importorg.springframework.beans.factory.annotation.Value;importorg.springframework.stereotype.Component;importorg.springframework.util.StringUtils;import java.util.*;/*** @description: 语音识别工具类
*@author: zhucj
* @date: 2019-11-23 15:30*/@Component
@Slf4jpublic classASRUtil {
@Value("${tencent.secretId}")privateString sercretId;
@Value("${tencent.secretKey}")privateString sercretKey;/*** 一句话识别
*@paramparam
*@return
*/
publicR sentenceRecognition(SentenceRecognition param){//获取公共请求参数
TreeMap treeMap = createPublicMap("SentenceRecognition", "2019-06-14");
HashMap hashMap = new HashMap<>();
hashMap.put("ProjectId",0);
hashMap.put("SubServiceType",2);
hashMap.put("EngSerViceType","8k");
hashMap.put("SourceType",param.getSourceType());
verifyVoiceFormat(param.getVoiceFormat());
hashMap.put("VoiceFormat",param.getVoiceFormat());
hashMap.put("UsrAudioKey",IDUtil.createIdbyUUID());if (Objects.equals(0,param.getSourceType())){if(StringUtils.isEmpty(param.getUrl())){throw new ASRRuntimeException(SystemConstants.PARAM_INCORRECT_CODE,"传入语音Url类型时,传入的ur