| @@ -17,6 +17,7 @@ import com.iformall.mapper.PersonPhotoMapper; | |||||
| import com.iformall.service.sm.MaterialMouldService; | import com.iformall.service.sm.MaterialMouldService; | ||||
| import com.iformall.service.sm.MouldPatchSignService; | import com.iformall.service.sm.MouldPatchSignService; | ||||
| import com.iformall.service.sm.PersonPhotoService; | import com.iformall.service.sm.PersonPhotoService; | ||||
| import com.iformall.sm.AiCheckPhotoResult; | |||||
| import com.iformall.sm.AiVideoHelper; | import com.iformall.sm.AiVideoHelper; | ||||
| import com.iformall.utils.Base64Util; | import com.iformall.utils.Base64Util; | ||||
| import com.iformall.utils.HttpUtil; | import com.iformall.utils.HttpUtil; | ||||
| @@ -133,16 +134,7 @@ public class PersonPhotoServiceImpl implements PersonPhotoService { | |||||
| @Override | @Override | ||||
| public ResultData checkPhoto(String material) { | public ResultData checkPhoto(String material) { | ||||
| String url = "http://nas.pucao.cn:2002/image_qualit"; | |||||
| String result = AiVideoHelper.doPost(url, Base64Util.imageUrlToBase64(material)); | |||||
| if (StringUtils.isNotEmpty(result)) { | |||||
| JSONObject result1 = JSON.parseObject(result); | |||||
| String status = result1.getString("status"); | |||||
| JSONObject jsonObject = JSON.parseObject(status); | |||||
| Integer code = jsonObject.getInteger("code"); | |||||
| String msg = jsonObject.getString("msg"); | |||||
| return new ResultData(code, msg); | |||||
| } | |||||
| return new ResultData("图片质量审核失败"); | |||||
| AiCheckPhotoResult result = AiVideoHelper.checkPhoto(Base64Util.imageUrlToBase64(material)); | |||||
| return new ResultData(result.getCode(), result.getMsg()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -206,7 +206,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| msg = "声音数据异常"; | msg = "声音数据异常"; | ||||
| } | } | ||||
| if(StringUtils.isBlank(voiceMouldSmId) || StringUtils.isBlank(voiceMaterialUrl)){ | |||||
| if(StringUtils.isBlank(voiceMouldSmId) && StringUtils.isBlank(voiceMaterialUrl)){ | |||||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | ||||
| videoUpd.setVideoMsg(msg); | videoUpd.setVideoMsg(msg); | ||||
| this.saveOrUpdate(videoUpd); | this.saveOrUpdate(videoUpd); | ||||
| @@ -232,7 +232,13 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| Integer sex = jsonObject.getInteger("sex"); | Integer sex = jsonObject.getInteger("sex"); | ||||
| if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | ||||
| param.setGen_txt(paperwork); | param.setGen_txt(paperwork); | ||||
| param.setGender(sex.toString()); | |||||
| if (sex == 1){ | |||||
| param.setGender("male"); | |||||
| }else if (sex == 2){ | |||||
| param.setGender("female"); | |||||
| }else { | |||||
| param.setGender("unknown"); | |||||
| } | |||||
| param.setUrl("None"); | param.setUrl("None"); | ||||
| } else if (EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)) { | } else if (EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)) { | ||||
| param.setGen_txt("None"); | param.setGen_txt("None"); | ||||
| @@ -0,0 +1,13 @@ | |||||
| package com.iformall.sm; | |||||
| import io.swagger.models.auth.In; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class AiCheckPhotoResult { | |||||
| private boolean success; | |||||
| private String msg; | |||||
| private Integer code; | |||||
| } | |||||
| @@ -32,6 +32,7 @@ public class AiVideoHelper { | |||||
| public static String uri = "http://nas.pucao.cn:2001"; | public static String uri = "http://nas.pucao.cn:2001"; | ||||
| public static String url = "http://nas.pucao.cn:2002/img_talking"; | public static String url = "http://nas.pucao.cn:2002/img_talking"; | ||||
| public static String url1 = "http://nas.pucao.cn:2002/image_qualit"; | |||||
| public static String doPost(String url, String params) { | public static String doPost(String url, String params) { | ||||
| return HttpUtil.doAiVideoPost(url,params); | return HttpUtil.doAiVideoPost(url,params); | ||||
| } | } | ||||
| @@ -130,6 +131,38 @@ public class AiVideoHelper { | |||||
| return result; | return result; | ||||
| } | } | ||||
| public static AiCheckPhotoResult checkPhoto(String str) { | |||||
| log.info("生成视频start request:" + str); | |||||
| String response = doPost(url1, JSONObject.toJSONString(str)); | |||||
| log.info("生成视频end response:" + response); | |||||
| AiCheckPhotoResult result = new AiCheckPhotoResult(); | |||||
| if (StringUtils.isBlank(response)) { | |||||
| result.setSuccess(false); | |||||
| result.setMsg("图片质量审核失败,请稍后重试"); | |||||
| return result; | |||||
| } | |||||
| JSONObject jsonObject = JSON.parseObject(response); | |||||
| JSONObject status = jsonObject.getJSONObject("status"); | |||||
| Integer code = status.getInteger("code"); | |||||
| String msg = status.getString("msg"); | |||||
| if (code == null) { | |||||
| result.setSuccess(false); | |||||
| result.setMsg("请求生成视频异常,请稍后重试"); | |||||
| return result; | |||||
| } | |||||
| if (code.intValue() == 2000) { | |||||
| result.setCode(code); | |||||
| result.setSuccess(true); | |||||
| result.setMsg(msg); | |||||
| } else { | |||||
| result.setCode(code); | |||||
| result.setSuccess(false); | |||||
| result.setMsg(msg); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| // AiVideoParam videoParam = new AiVideoParam(); | // AiVideoParam videoParam = new AiVideoParam(); | ||||
| // videoParam.setGen_txt("我写了一篇小说,你帮我看看。"); | // videoParam.setGen_txt("我写了一篇小说,你帮我看看。"); | ||||
| @@ -152,10 +185,10 @@ public class AiVideoHelper { | |||||
| // AiVideoResult video = AiVideoHelper.createVideo(videoParam); | // AiVideoResult video = AiVideoHelper.createVideo(videoParam); | ||||
| AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | ||||
| param.setGen_txt("我写了一篇小说,你帮我看看。"); | |||||
| param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/personmould/16739389169485046_nVi875Ej_grace_1080.jpg")); | |||||
| param.setGen_txt("dasdadklfjskjf"); | |||||
| param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/digitalperson/16760216806604820_cSHoijDX_matting.png")); | |||||
| param.setGender("male"); | param.setGender("male"); | ||||
| param.setVoice_id("zh-CN-XiaohanNeural"); | |||||
| param.setVoice_id("en-US-BrandonNeural"); | |||||
| param.setVoice_style("default"); | param.setVoice_style("default"); | ||||
| param.setUrl("None"); | param.setUrl("None"); | ||||
| AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | ||||