| @@ -50,6 +50,8 @@ public class JsonImportController { | |||
| language.setLocal(bean.getLocale()); | |||
| language.setName(bean.getLocaleName()); | |||
| language.setIsDel(0); | |||
| HashMap<String, String> map = initNameMap(); | |||
| language.setChineseName(map.get(bean.getLocale())); | |||
| set.add(language); | |||
| } | |||
| voiceLanguageMapper.saveBatch(set); | |||
| @@ -64,9 +66,10 @@ public class JsonImportController { | |||
| voiceInfo.setId(voiceMould.getId()); | |||
| } | |||
| VoiceLanguage voiceLanguage = voiceLanguageMapper.selectOne(new QueryWrapper<VoiceLanguage>().lambda().eq(VoiceLanguage::getLocal, bean.getLocale())); | |||
| logger.info(voiceLanguage.toString()); | |||
| if (!ObjectUtils.isEmpty(voiceLanguage)) { | |||
| voiceInfo.setLanguageId(voiceLanguage.getId()); | |||
| }else { | |||
| } else { | |||
| System.out.println(bean.getName()); | |||
| } | |||
| String gender = bean.getGender(); | |||
| @@ -86,6 +89,13 @@ public class JsonImportController { | |||
| if (!StringUtils.isEmpty(bean.getStyleList())) { | |||
| voiceInfo.setStyleList(JSON.toJSONString(bean.getStyleList())); | |||
| } | |||
| HashMap<String, Integer> map = initAgeMap(); | |||
| for (Map.Entry<String, Integer> entry : map.entrySet()) { | |||
| if (bean.getShortName().equals(entry.getKey())){ | |||
| voiceInfo.setAgeType(entry.getValue()); | |||
| } | |||
| } | |||
| voiceInfo.setCreateDate(date); | |||
| voiceInfo.setUpdateDate(date); | |||
| list1.add(voiceInfo); | |||
| @@ -93,4 +103,220 @@ public class JsonImportController { | |||
| voiceMapper.saveBatch(list1); | |||
| return new ResultData("导入完成"); | |||
| } | |||
| } | |||
| public HashMap<String, Integer> initAgeMap() { | |||
| HashMap<String, Integer> map = new HashMap<>(); | |||
| map.put("zh-CN-XiaochenNeural", 3); | |||
| map.put("zh-CN-XiaohanNeural", 3); | |||
| map.put("zh-CN-XiaomengNeural", 3); | |||
| map.put("zh-CN-XiaomoNeural", 3); | |||
| map.put("zh-CN-XiaoqiuNeural", 4); | |||
| map.put("zh-CN-XiaoruiNeural", 5); | |||
| map.put("zh-CN-XiaoshuangNeural", 1); | |||
| map.put("zh-CN-XiaoxiaoNeural", 3); | |||
| map.put("zh-CN-XiaoxuanNeural", 3); | |||
| map.put("zh-CN-XiaoyanNeural", 3); | |||
| map.put("zh-CN-XiaoyiNeural", 3); | |||
| map.put("zh-CN-XiaoyouNeural", 1); | |||
| map.put("zh-CN-XiaozhenNeural", 3); | |||
| map.put("zh-CN-YunfengNeural", 4); | |||
| map.put("zh-CN-YunhaoNeural", 3); | |||
| map.put("zh-CN-YunjianNeural", 4); | |||
| map.put("zh-CN-YunxiaNeural", 2); | |||
| map.put("zh-CN-YunxiNeural", 3); | |||
| map.put("zh-CN-YunyangNeural", 3); | |||
| map.put("zh-CN-YunyeNeural", 4); | |||
| map.put("zh-CN-YunzeNeural", 4); | |||
| map.put("wuu-CN-XiaotongNeural", 3); | |||
| map.put("wuu-CN-YunzheNeural", 3); | |||
| map.put("yue-CN-XiaoMinNeural", 3); | |||
| map.put("yue-CN-YunSongNeural", 3); | |||
| map.put("zh-CN-henan-YundengNeural", 3); | |||
| map.put("zh-CN-liaoning-XiaobeiNeural", 3); | |||
| map.put("zh-CN-shaanxi-XiaoniNeural", 3); | |||
| map.put("zh-CN-shandong-YunxiangNeural", 3); | |||
| map.put("zh-CN-sichuan-YunxiNeural", 3); | |||
| map.put("zh-HK-HiuGaaiNeural", 3); | |||
| map.put("zh-HK-HiuMaanNeural", 3); | |||
| map.put("zh-HK-WanLungNeural", 3); | |||
| map.put("zh-TW-HsiaoChenNeural", 3); | |||
| map.put("zh-TW-HsiaoYuNeural", 3); | |||
| map.put("zh-TW-YunJheNeural", 3); | |||
| map.put("en-US-AmberNeural", 3); | |||
| map.put("en-US-AnaNeural", 1); | |||
| map.put("en-US-AriaNeural", 3); | |||
| map.put("en-US-AshleyNeural", 3); | |||
| map.put("en-US-CoraNeural", 3); | |||
| map.put("en-US-ElizabethNeural", 3); | |||
| map.put("en-US-JaneNeural", 3); | |||
| map.put("en-US-JennyNeural", 3); | |||
| map.put("en-US-MichelleNeural", 3); | |||
| map.put("en-US-MonicaNeural", 3); | |||
| map.put("en-US-NancyNeural", 3); | |||
| map.put("en-US-SaraNeural", 3); | |||
| map.put("en-US-BrandonNeural", 3); | |||
| map.put("en-US-ChristopherNeural", 3); | |||
| map.put("en-US-DavisNeural", 3); | |||
| map.put("en-US-EricNeural", 3); | |||
| map.put("en-US-GuyNeural", 3); | |||
| map.put("en-US-JacobNeural", 3); | |||
| map.put("en-US-JasonNeural", 3); | |||
| map.put("en-US-RogerNeural", 3); | |||
| map.put("en-US-SteffanNeural", 3); | |||
| map.put("en-US-TonyNeural", 3); | |||
| return map; | |||
| } | |||
| public HashMap<String, String> initNameMap() { | |||
| HashMap<String, String> map = new HashMap<>(); | |||
| map.put("af-ZA", "南非荷兰语(南非)"); | |||
| map.put("am-ET", "阿姆哈拉语(埃塞俄比亚)"); | |||
| map.put("ar-AE", "阿拉伯语(阿拉伯联合酋长国)"); | |||
| map.put("ar-BH", "阿拉伯语(巴林)"); | |||
| map.put("ar-DZ", "阿拉伯语(阿尔及利亚)"); | |||
| map.put("ar-EG", "阿拉伯语(埃及)"); | |||
| map.put("ar-IQ", "阿拉伯语(伊拉克)"); | |||
| map.put("ar-JO", "阿拉伯语(约旦)"); | |||
| map.put("ar-KW", "阿拉伯语(科威特)"); | |||
| map.put("ar-LB", "阿拉伯语(黎巴嫩)"); | |||
| map.put("ar-LY", "阿拉伯语(利比亚)"); | |||
| map.put("ar-MA", "阿拉伯语(摩洛哥)"); | |||
| map.put("ar-OM", "阿拉伯语(阿曼)"); | |||
| map.put("ar-QA", "阿拉伯语(卡塔尔)"); | |||
| map.put("ar-SA", "阿拉伯语(沙特阿拉伯)"); | |||
| map.put("ar-SY", "阿拉伯语(叙利亚)"); | |||
| map.put("ar-TN", "阿拉伯语(突尼斯)"); | |||
| map.put("ar-YE", "阿拉伯语(也门)"); | |||
| map.put("az-AZ", "阿塞拜疆语(拉丁语,阿塞拜疆)"); | |||
| map.put("bg-BG", "保加利亚语(保加利亚)"); | |||
| map.put("bn-BD", "孟加拉语(孟加拉国)"); | |||
| map.put("bn-IN", "孟加拉语(印度)"); | |||
| map.put("bs-BA", "波斯尼亚语(波斯尼亚和黑塞哥维那)"); | |||
| map.put("ca-ES", "加泰罗尼亚语(西班牙)"); | |||
| map.put("cs-CZ", "捷克语(捷克)"); | |||
| map.put("cy-GB", "威尔士语(英国)"); | |||
| map.put("da-DK", "丹麦语(丹麦)"); | |||
| map.put("de-AT", "德语(奥地利)"); | |||
| map.put("de-CH", "德语(瑞士)"); | |||
| map.put("de-DE", "德语(德国)"); | |||
| map.put("el-GR", "希腊语(希腊)"); | |||
| map.put("en-AU", "英语(澳大利亚)"); | |||
| map.put("en-CA", "英语(加拿大)"); | |||
| map.put("en-GB", "英语(英国)"); | |||
| map.put("en-HK", "英语(香港特別行政区)"); | |||
| map.put("en-IE", "英语(爱尔兰)"); | |||
| map.put("en-IN", "英语(印度)"); | |||
| map.put("en-KE", "英语(肯尼亚)"); | |||
| map.put("en-NG", "英语(尼日利亚)"); | |||
| map.put("en-NZ", "英语(新西兰)"); | |||
| map.put("en-PH", "英语(菲律宾)"); | |||
| map.put("en-SG", "英语(新加坡)"); | |||
| map.put("en-TZ", "英语(坦桑尼亚)"); | |||
| map.put("en-US", "英语(美国)"); | |||
| map.put("en-ZA", "英语(南非)"); | |||
| map.put("es-AR", "西班牙语(阿根廷)"); | |||
| map.put("es-BO", "西班牙语(玻利维亚)"); | |||
| map.put("es-CL", "西班牙语(智利)"); | |||
| map.put("es-CO", "西班牙语(哥伦比亚)"); | |||
| map.put("es-CR", "西班牙语(哥斯达黎加)"); | |||
| map.put("es-CU", "西班牙语(古巴)"); | |||
| map.put("es-DO", "西班牙语(多米尼加共和国)"); | |||
| map.put("es-EC", "西班牙语(厄瓜多尔)"); | |||
| map.put("es-ES", "西班牙语(西班牙)"); | |||
| map.put("es-GQ", "西班牙语(赤道几内亚)"); | |||
| map.put("es-GT", "西班牙语(危地马拉)"); | |||
| map.put("es-HN", "西班牙语(洪都拉斯)"); | |||
| map.put("es-MX", "西班牙语(墨西哥)"); | |||
| map.put("es-NI", "西班牙(尼加拉瓜)"); | |||
| map.put("es-PA", "西班牙语(巴拿马)"); | |||
| map.put("es-PE", "西班牙语(秘鲁)"); | |||
| map.put("es-PR", "西班牙语(波多黎各)"); | |||
| map.put("es-PY", "西班牙语(巴拉圭)"); | |||
| map.put("es-SV", "西班牙语(萨尔瓦多)"); | |||
| map.put("es-US", "西班牙语(美国)"); | |||
| map.put("es-UY", "西班牙语(乌拉圭)"); | |||
| map.put("es-VE", "西班牙语(委内瑞拉)"); | |||
| map.put("et-EE", "爱沙尼亚语(爱沙尼亚)"); | |||
| map.put("eu-ES", "巴斯克语"); | |||
| map.put("fa-IR", "波斯语(伊朗)"); | |||
| map.put("fi-FI", "芬兰语(芬兰)"); | |||
| map.put("fil-PH", "菲律宾语(菲律宾)"); | |||
| map.put("fr-BE", "法语(比利时)"); | |||
| map.put("fr-CA", "法语(加拿大)"); | |||
| map.put("fr-CH", "法语(瑞士)"); | |||
| map.put("fr-FR", "法语(法国)"); | |||
| map.put("ga-IE", "爱尔兰语(爱尔兰)"); | |||
| map.put("gl-ES", "加利西亚语"); | |||
| map.put("gu-IN", "古吉拉特语(印度)"); | |||
| map.put("he-IL", "希伯来语(以色列)"); | |||
| map.put("hi-IN", "印地语(印度)"); | |||
| map.put("hr-HR", "克罗地亚语(克罗地亚)"); | |||
| map.put("hu-HU", "匈牙利语(匈牙利)"); | |||
| map.put("hy-AM", "亚美尼亚语(亚美尼亚)"); | |||
| map.put("id-ID", "印度尼西亚语(印度尼西亚)"); | |||
| map.put("is-IS", "冰岛语(冰岛)"); | |||
| map.put("it-IT", "意大利语(意大利)"); | |||
| map.put("ja-JP", "日语(日本)"); | |||
| map.put("jv-ID", "爪哇语(拉丁语、印度尼西亚)"); | |||
| map.put("ka-GE", "格鲁吉亚语(格鲁吉亚)"); | |||
| map.put("kk-KZ", "哈萨克语(哈萨克斯坦)"); | |||
| map.put("km-KH", "高棉语(柬埔寨)"); | |||
| map.put("kn-IN", "卡纳达语(印度)"); | |||
| map.put("ko-KR", "韩语(韩国)"); | |||
| map.put("lo-LA", "老挝语(老挝)"); | |||
| map.put("lt-LT", "立陶宛语(立陶宛)"); | |||
| map.put("lv-LV", "拉脱维亚语(拉脱维亚)"); | |||
| map.put("mk-MK", "马其顿语(北马其顿)"); | |||
| map.put("ml-IN", "马拉雅拉姆语(印度)"); | |||
| map.put("mn-MN", "蒙古语(蒙古)"); | |||
| map.put("mr-IN", "马拉地语(印度)"); | |||
| map.put("ms-MY", "马来语(马来西亚)"); | |||
| map.put("mt-MT", "马耳他语(马耳他)"); | |||
| map.put("my-MM", "缅甸语(缅甸)"); | |||
| map.put("nb-NO", "书面挪威语(挪威)"); | |||
| map.put("ne-NP", "尼泊尔语(尼泊尔)"); | |||
| map.put("nl-BE", "荷兰语(比利时)"); | |||
| map.put("nl-NL", "荷兰语(荷兰)"); | |||
| map.put("pl-PL", "波兰语(波兰)"); | |||
| map.put("ps-AF", "普什图语(阿富汗)"); | |||
| map.put("pt-BR", "葡萄牙语(巴西)"); | |||
| map.put("pt-PT", "葡萄牙语(葡萄牙)"); | |||
| map.put("ro-RO", "罗马尼亚语(罗马尼亚)"); | |||
| map.put("ru-RU", "俄语(俄罗斯)"); | |||
| map.put("si-LK", "僧伽罗语(斯里兰卡)"); | |||
| map.put("sk-SK", "斯洛伐克语(斯洛伐克)"); | |||
| map.put("sl-SI", "斯洛文尼亚语(斯洛文尼亚)"); | |||
| map.put("so-SO", "索马里语(索马里)"); | |||
| map.put("sq-AL", "阿尔巴尼亚语(阿尔巴尼亚)"); | |||
| map.put("sr-RS", "塞尔维亚语(西里尔文,塞尔维亚)"); | |||
| map.put("su-ID", "巽他语(印度尼西亚)"); | |||
| map.put("sv-SE", "瑞典语(瑞典)"); | |||
| map.put("sw-KE", "斯瓦希里语(肯尼亚)"); | |||
| map.put("sw-TZ", "斯瓦希里语(坦桑尼亚)"); | |||
| map.put("ta-IN", "泰米尔语(印度)"); | |||
| map.put("ta-LK", "泰米尔语(斯里兰卡)"); | |||
| map.put("ta-MY", "泰米尔语(马来西亚)"); | |||
| map.put("ta-SG", "泰米尔语(新加坡)"); | |||
| map.put("te-IN", "泰卢固语(印度)"); | |||
| map.put("th-TH", "泰语(泰国)"); | |||
| map.put("tr-TR", "土耳其语(土耳其)"); | |||
| map.put("uk-UA", "乌克兰语(乌克兰)"); | |||
| map.put("ur-IN", "乌尔都语(印度)"); | |||
| map.put("ur-PK", "乌尔都语(巴基斯坦)"); | |||
| map.put("uz-UZ", "乌兹别克语(拉丁语,乌兹别克斯坦)"); | |||
| map.put("vi-VN", "越南语(越南)"); | |||
| map.put("wuu-CN", "中文(吴语,简体)"); | |||
| map.put("yue-CN", "中文(粤语,简体)"); | |||
| map.put("zh-CN", "中文(普通话,简体)"); | |||
| map.put("zh-CN-henan", "中文(中原官话河南,简体)"); | |||
| map.put("zh-CN-liaoning", "中文(东北官话,简体)"); | |||
| map.put("zh-CN-shaanxi", "中文(中原官话陕西,简体)"); | |||
| map.put("zh-CN-shandong", "中文(冀鲁官话,简体)"); | |||
| map.put("zh-CN-sichuan", "中文(西南普通话,简体)"); | |||
| map.put("zh-HK", "中文(粤语,繁体)"); | |||
| map.put("zh-TW", "中文(台湾普通话,繁体)"); | |||
| map.put("zu-ZA", "祖鲁语(南非)"); | |||
| return map; | |||
| } | |||
| } | |||
| @@ -86,7 +86,7 @@ public class PersonPhotoController extends BaseController { | |||
| } | |||
| @ApiOperation("图片质量审核接口") | |||
| @PostMapping("checkPhoto") | |||
| @GetMapping("checkPhoto") | |||
| @ApiImplicitParam(name = "material", value = "material", dataType = "String", paramType = "query", required = true) | |||
| public ResultData checkPhoto(String material) { | |||
| logger.debug("[" + getIpAddr() + "] PersonPhotoController::checkPhoto"); | |||
| @@ -7,9 +7,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.sm.*; | |||
| import com.iformall.enums.EnumMouldSendType; | |||
| import com.iformall.enums.EnumVideoStatus; | |||
| import com.iformall.enums.EnumaMouldPatchStatus; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.sm.*; | |||
| import com.iformall.video.VideoFactory; | |||
| @@ -24,6 +22,8 @@ import org.checkerframework.checker.units.qual.A; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.scheduling.annotation.AsyncResult; | |||
| import org.springframework.util.ObjectUtils; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| @@ -178,6 +178,70 @@ public class PhotoSpeakVideoController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"视频已生成完成"); | |||
| } | |||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | |||
| videoUpd.setId(mouldVideo.getId()); | |||
| if (mouldVideo.getPersonPhotoId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到人物照片"); | |||
| } | |||
| if(StringUtils.isBlank(mouldVideo.getPersonPhotoUrl())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未查询到人物照片地址"); | |||
| } | |||
| videoUpd.setPersonPhotoId(mouldVideo.getPersonPhotoId()); | |||
| videoUpd.setPersonPhotoUrl(mouldVideo.getPersonPhotoUrl()); | |||
| Integer voiceFrom = mouldVideo.getVoiceFrom(); | |||
| videoUpd.setVoiceFrom(voiceFrom); | |||
| if(EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)){ | |||
| String voiceMouldSmId = null; | |||
| try{ | |||
| JSONObject personMouldObject = JSONObject.parseObject(mouldVideo.getVoiceMouldSm()); | |||
| voiceMouldSmId = personMouldObject.getString("mouldSmId"); | |||
| videoUpd.setVoiceMouldSm(voiceMouldSmId); | |||
| videoUpd.setPaperwork(mouldVideo.getPaperwork()); | |||
| videoUpd.setVoiceMouldSm(mouldVideo.getVoiceMouldSm()); | |||
| }catch(Exception e){ | |||
| logger.info(e.getMessage()); | |||
| } | |||
| if(StringUtils.isBlank(voiceMouldSmId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数错误,未找到声音模板数据"); | |||
| } | |||
| if(StringUtils.isBlank(mouldVideo.getPaperwork())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未填写视频文案数据"); | |||
| } | |||
| //TODO 设置预估时长 | |||
| // videoUpd.setVideoTime(); | |||
| }else if(EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)){ | |||
| String voiceMaterialUrl = mouldVideo.getVoiceMaterialUrl(); | |||
| VoiceMaterial voiceMaterial = voiceMaterialService.getById(mouldVideo.getVoiceMaterialId()); | |||
| if(StringUtils.isBlank(voiceMaterialUrl)){ | |||
| voiceMaterialService.handVideoUrl(voiceMaterial); | |||
| voiceMaterialUrl = voiceMaterial.getMaterial(); | |||
| videoUpd.setVoiceMaterialUrl(voiceMaterialUrl); | |||
| } | |||
| if(StringUtils.isBlank(voiceMaterialUrl)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到上传声音文件"); | |||
| } | |||
| if(voiceMaterial.getTime() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"音频时长为空"); | |||
| } | |||
| videoUpd.setVideoTime(String.valueOf(voiceMaterial.getTime())); | |||
| } else if (EnumVoiceFrom.MUSIC.getCode().equals(voiceFrom)) { | |||
| Long musicId = mouldVideo.getMusicId(); | |||
| MusicInfo musicInfo = musicInfoService.getById(musicId); | |||
| if (ObjectUtils.isEmpty(musicInfo)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到音乐文件"); | |||
| } | |||
| if (StringUtils.isBlank(musicInfo.getUrl())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"音乐文件错误"); | |||
| } | |||
| if(musicInfo.getTime() == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"音乐时长为空"); | |||
| } | |||
| videoUpd.setVoiceMaterialUrl(musicInfo.getUrl()); | |||
| videoUpd.setVideoTime(String.valueOf(musicInfo.getTime())); | |||
| } else { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"声音数据异常"); | |||
| } | |||
| PhotoSpeakVideo mouldVideoUpd = new PhotoSpeakVideo(); | |||
| mouldVideoUpd.setId(record.getId()); | |||
| mouldVideoUpd.setVideoStatus(EnumVideoStatus.ing.getCode()); | |||
| @@ -185,7 +249,7 @@ public class PhotoSpeakVideoController extends BaseController { | |||
| mouldVideoUpd.setCreateVideoDate(new Date()); | |||
| photoSpeakVideoService.saveOrUpdate(mouldVideoUpd); | |||
| photoSpeakVideoService.createVideo(mouldVideo,true); | |||
| photoSpeakVideoService.createVideo(videoUpd); | |||
| return new ResultData(); | |||
| } | |||
| @@ -101,7 +101,7 @@ public class SDKController extends BaseController { | |||
| mouldVideoUpd.setVideoMsg(""); | |||
| mouldVideoUpd.setCreateVideoDate(new Date()); | |||
| photoSpeakVideoService.saveOrUpdate(mouldVideoUpd); | |||
| photoSpeakVideoService.createVideo(mouldVideo, true); | |||
| photoSpeakVideoService.createVideo(mouldVideo); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -57,8 +57,7 @@ public class PhotoSpeakSchedule { | |||
| if (list != null && list.size() > 0) { | |||
| for (PhotoSpeakVideo video : list) { | |||
| try { | |||
| Future future = photoSpeakVideoService.createVideo(video,false); | |||
| future.get(); | |||
| photoSpeakVideoService.createVideo(video); | |||
| } catch (Exception e) { | |||
| logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); | |||
| } | |||
| @@ -1,114 +1,35 @@ | |||
| package com.iformall.domain.po.json; | |||
| import com.fasterxml.jackson.annotation.JsonProperty; | |||
| import lombok.Data; | |||
| import java.util.List; | |||
| @Data | |||
| public class JsonRootBean { | |||
| private String name; | |||
| private String displayName; | |||
| private String localName; | |||
| private String shortName; | |||
| private String gender; | |||
| private String locale; | |||
| private String localeName; | |||
| private String sampleRateHertz; | |||
| private String voiceType; | |||
| private String status; | |||
| private String wordsPerMinute; | |||
| private List<String> styleList; | |||
| public String getName() { | |||
| return name; | |||
| } | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| public String getDisplayName() { | |||
| return displayName; | |||
| } | |||
| public void setDisplayName(String displayName) { | |||
| this.displayName = displayName; | |||
| } | |||
| public String getLocalName() { | |||
| return localName; | |||
| } | |||
| public void setLocalName(String localName) { | |||
| this.localName = localName; | |||
| } | |||
| public String getShortName() { | |||
| return shortName; | |||
| } | |||
| public void setShortName(String shortName) { | |||
| this.shortName = shortName; | |||
| } | |||
| public String getGender() { | |||
| return gender; | |||
| } | |||
| public void setGender(String gender) { | |||
| this.gender = gender; | |||
| } | |||
| public String getLocale() { | |||
| return locale; | |||
| } | |||
| public void setLocale(String locale) { | |||
| this.locale = locale; | |||
| } | |||
| public String getLocaleName() { | |||
| return localeName; | |||
| } | |||
| public void setLocaleName(String localeName) { | |||
| this.localeName = localeName; | |||
| } | |||
| public String getSampleRateHertz() { | |||
| return sampleRateHertz; | |||
| } | |||
| public void setSampleRateHertz(String sampleRateHertz) { | |||
| this.sampleRateHertz = sampleRateHertz; | |||
| } | |||
| public String getVoiceType() { | |||
| return voiceType; | |||
| } | |||
| public void setVoiceType(String voiceType) { | |||
| this.voiceType = voiceType; | |||
| } | |||
| public String getStatus() { | |||
| return status; | |||
| } | |||
| public void setStatus(String status) { | |||
| this.status = status; | |||
| } | |||
| public String getWordsPerMinute() { | |||
| return wordsPerMinute; | |||
| } | |||
| public void setWordsPerMinute(String wordsPerMinute) { | |||
| this.wordsPerMinute = wordsPerMinute; | |||
| } | |||
| public List<String> getStyleList() { | |||
| return styleList; | |||
| } | |||
| @JsonProperty("Name") | |||
| private String Name; | |||
| @JsonProperty("DisplayName") | |||
| private String DisplayName; | |||
| @JsonProperty("LocalName") | |||
| private String LocalName; | |||
| @JsonProperty("ShortName") | |||
| private String ShortName; | |||
| @JsonProperty("Gender") | |||
| private String Gender; | |||
| @JsonProperty("Locale") | |||
| private String Locale; | |||
| @JsonProperty("LocaleName") | |||
| private String LocaleName; | |||
| @JsonProperty("SampleRateHertz") | |||
| private String SampleRateHertz; | |||
| @JsonProperty("VoiceType") | |||
| private String VoiceType; | |||
| @JsonProperty("Status") | |||
| private String Status; | |||
| @JsonProperty("WordsPerMinute") | |||
| private String WordsPerMinute; | |||
| @JsonProperty("StyleList") | |||
| private List<String> StyleList; | |||
| public void setStyleList(List<String> styleList) { | |||
| this.styleList = styleList; | |||
| } | |||
| } | |||
| @@ -14,7 +14,7 @@ import java.util.List; | |||
| /** | |||
| * 声音表 | |||
| */ | |||
| @TableName(value = "voice_info") | |||
| @TableName(value = "voice_info_copy1") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| @@ -13,7 +13,7 @@ import java.util.Objects; | |||
| /** | |||
| * 语种表 | |||
| */ | |||
| @TableName(value = "voice_language") | |||
| @TableName(value = "voice_language_copy1") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| @@ -121,4 +121,6 @@ public class VoiceMaterial extends TenantEntity { | |||
| private Integer type; | |||
| private Double time; | |||
| } | |||
| @@ -16,6 +16,7 @@ public enum EnumVideoStatus { | |||
| upload_ing(4,"上传视频中"), | |||
| upload_success(5,"上传视频成功"), | |||
| upload_fail(6,"上传视频失败") | |||
| //TODO 接口调用成功、失败状态 | |||
| ; | |||
| @@ -45,7 +45,7 @@ public interface PhotoSpeakVideoService { | |||
| */ | |||
| void deleteById(Long id); | |||
| Future createVideo(PhotoSpeakVideo mouldVideo,Boolean flag); | |||
| ResultData createVideo(PhotoSpeakVideo mouldVideo); | |||
| void uploadVideo(PhotoSpeakVideo mouldVideo); | |||
| @@ -177,205 +177,34 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
| photoSpeakVideoMapper.deleteById(id); | |||
| } | |||
| @Async | |||
| @Override | |||
| public Future createVideo(PhotoSpeakVideo photoSpeakVideo,Boolean flag) { | |||
| boolean isCreate = false; | |||
| String msg = ""; | |||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | |||
| videoUpd.setId(photoSpeakVideo.getId()); | |||
| String personPhotoUrl = null; | |||
| if (photoSpeakVideo.getPersonPhotoId() == null) { | |||
| msg = "未查询到人物照片"; | |||
| } else { | |||
| personPhotoUrl = photoSpeakVideo.getPersonPhotoUrl(); | |||
| PersonPhoto personPhotoInfo = personPhotoService.getById(photoSpeakVideo.getPersonPhotoId()); | |||
| //如果是上传图片就去检验合法 | |||
| if (EnumMouldSendType.build.getCode().equals(personPhotoInfo.getSendType())) { | |||
| //校验图片是否合法 | |||
| AiCheckPhotoParam param = new AiCheckPhotoParam(); | |||
| param.setImg(Base64Util.imageUrlToBase64(personPhotoUrl)); | |||
| AiCheckPhotoResult result = AiVideoHelper.checkPhoto(param); | |||
| if (result.getCode() != 2000) { | |||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| videoUpd.setVideoMsg("图片质量审核失败:" + result.getMsg()); | |||
| this.saveOrUpdate(videoUpd); | |||
| return new AsyncResult<>(0); | |||
| } | |||
| } | |||
| } | |||
| if(StringUtils.isBlank(personPhotoUrl)){ | |||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| videoUpd.setVideoMsg(msg); | |||
| this.saveOrUpdate(videoUpd); | |||
| return new AsyncResult<>(0); | |||
| } | |||
| Integer voiceFrom = photoSpeakVideo.getVoiceFrom(); | |||
| String voiceMouldSmId = null; | |||
| String voiceType = "default";//默认 | |||
| Integer sex = 1; | |||
| Double videoTime = null;//用户创建视频的时长 | |||
| //TODO 关闭用户相关流程 | |||
| UserCreateVideoNum videoNum = userCreateVideoNumService.queryInfoByUserId(photoSpeakVideo.getUserId()); | |||
| // if (videoNum == null) { | |||
| // videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| // videoUpd.setVideoMsg("用户没有创建视频时长"); | |||
| // this.saveOrUpdate(videoUpd); | |||
| // return new AsyncResult<>(0); | |||
| // } else { | |||
| // if (DateUtils.isDateAfter(String.valueOf(videoNum.getEffectiveDate()))) { | |||
| // videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| // videoUpd.setVideoMsg("有效期已到期"); | |||
| // this.saveOrUpdate(videoUpd); | |||
| // return new AsyncResult<>(0); | |||
| // } | |||
| // } | |||
| String voiceMaterialUrl = null; | |||
| if(EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)){ | |||
| try{ | |||
| JSONObject personMouldObject = JSONObject.parseObject(photoSpeakVideo.getVoiceMouldSm()); | |||
| voiceMouldSmId = personMouldObject.getString("mouldSmId"); | |||
| Integer speakType = personMouldObject.getInteger("speakType"); | |||
| Integer personType = personMouldObject.getInteger("personType"); | |||
| sex = personMouldObject.getInteger("sex"); | |||
| if(speakType != null && speakType > 0){ | |||
| voiceType = EnumSpeakType.getEnum(speakType).getMessage(); | |||
| }else if(personType != null && personType > 0){ | |||
| voiceType = EnumPersonType.getEnum(personType).getMessage(); | |||
| } | |||
| }catch(Exception e){} | |||
| if(StringUtils.isBlank(voiceMouldSmId)){ | |||
| msg = "参数错误,未找到声音模板数据"; | |||
| } | |||
| //获取视频时长 | |||
| AiPreviewParam param = new AiPreviewParam(); | |||
| if (StringUtils.isBlank(photoSpeakVideo.getPaperwork())){ | |||
| msg = "未填写视频文案数据"; | |||
| } | |||
| param.setGen_txt(photoSpeakVideo.getPaperwork().replaceAll(str, "[*]")); | |||
| param.setGender(sex == 1 ? "male" : "female"); | |||
| param.setVoice_id(voiceMouldSmId); | |||
| param.setVoice_style(voiceType); | |||
| AiPreviewResult result = AiVideoHelper.voicePreview(param); | |||
| if (result.isSuccess()) { | |||
| videoTime = result.getTime(); | |||
| } | |||
| }else if(EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)){ | |||
| voiceMaterialUrl = photoSpeakVideo.getVoiceMaterialUrl(); | |||
| VoiceMaterial voiceMaterial = voiceMaterialService.getById(photoSpeakVideo.getVoiceMaterialId()); | |||
| if(StringUtils.isBlank(voiceMaterialUrl)){ | |||
| voiceMaterialService.handVideoUrl(voiceMaterial); | |||
| voiceMaterialUrl = voiceMaterial.getMaterial(); | |||
| videoUpd.setVoiceMaterialUrl(voiceMaterialUrl); | |||
| } | |||
| if(StringUtils.isBlank(voiceMaterialUrl)){ | |||
| msg = "未找到上传声音文件"; | |||
| } | |||
| //判断用户时长是否够创建该视频 | |||
| VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(voiceMaterial.getVideoId()); | |||
| if (videoDetail.isSuccess() && StringUtils.isNotBlank(videoDetail.getDuration()) && !"0.0".equals(videoDetail.getDuration())) { | |||
| String duration = videoDetail.getDuration(); | |||
| videoTime = Double.valueOf(duration); | |||
| } | |||
| } else if (EnumVoiceFrom.MUSIC.getCode().equals(voiceFrom)) { | |||
| Long musicId = photoSpeakVideo.getMusicId(); | |||
| MusicInfo musicInfo = musicInfoService.getById(musicId); | |||
| if (ObjectUtils.isEmpty(musicInfo)) { | |||
| msg = "未找到音乐文件"; | |||
| } | |||
| voiceMaterialUrl = musicInfo.getUrl(); | |||
| if (StringUtils.isBlank(voiceMaterialUrl)) { | |||
| msg = "音乐文件错误"; | |||
| } | |||
| videoTime = Double.valueOf(musicInfo.getTime()); | |||
| } else { | |||
| msg = "声音数据异常"; | |||
| } | |||
| //判断获取创建的视频时长 | |||
| if (videoTime == null){ | |||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| videoUpd.setVideoMsg("获取创建的视频时长失败"); | |||
| this.saveOrUpdate(videoUpd); | |||
| return new AsyncResult<>(0); | |||
| } | |||
| //TODO 关闭用户相关流程 | |||
| //获取套餐信息 | |||
| // UserConsumptionPackage infoById = userConsumptionPackageService.getPackageInfoById(videoNum.getPackageId()); | |||
| // if (infoById == null){ | |||
| // videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| // videoUpd.setVideoMsg("套餐信息不存在"); | |||
| // this.saveOrUpdate(videoUpd); | |||
| // return new AsyncResult<>(0); | |||
| // } | |||
| // //生成视频时长不能超过对应套餐的时长 | |||
| // if (infoById.getChargeTime() < videoTime) { | |||
| // videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| // videoUpd.setVideoMsg("视频时长不能超过" + infoById.getChargeTime() + "s"); | |||
| // this.saveOrUpdate(videoUpd); | |||
| // return new AsyncResult<>(0); | |||
| // } | |||
| videoUpd.setVideoTime(String.valueOf(videoTime)); | |||
| if(StringUtils.isBlank(voiceMouldSmId) && StringUtils.isBlank(voiceMaterialUrl)){ | |||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| videoUpd.setVideoMsg(msg); | |||
| this.saveOrUpdate(videoUpd); | |||
| return new AsyncResult<>(0); | |||
| } | |||
| String paperwork = photoSpeakVideo.getPaperwork(); | |||
| if(EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom) && StringUtils.isBlank(paperwork)){ | |||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| videoUpd.setVideoMsg("未填写视频文案数据"); | |||
| this.saveOrUpdate(videoUpd); | |||
| return new AsyncResult<>(0); | |||
| } | |||
| double useCredit = 0; | |||
| //修改用户创建视频时间表 | |||
| if (flag) { | |||
| // //每秒消耗的积分 | |||
| // double i = (double)( videoNum.getVideoPrice() / 60); | |||
| // i = i < 1 ? 1.0 : i; //如果小于1 就直接取1 | |||
| // //用户创建视频需要时积分 | |||
| // useCredit = (videoTime * i); | |||
| // //判断用户积分是否足够 | |||
| // if (videoNum.getResidueCredits() < useCredit) { | |||
| // videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| // videoUpd.setVideoMsg("创建视频时长不足,请充值"); | |||
| // this.saveOrUpdate(videoUpd); | |||
| // return new AsyncResult<>(0); | |||
| // } | |||
| // useCredit = Math.round(useCredit); | |||
| //如果时间够,就去减去相对应的数据 | |||
| userCreateVideoNumService.addOrSubtractNumberOfTimes(1, videoNum, useCredit, videoTime); | |||
| } | |||
| public ResultData createVideo(PhotoSpeakVideo photoSpeakVideo) { | |||
| try { | |||
| AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | |||
| param.setImg(Base64Util.imageUrlToBase64(photoSpeakVideo.getPersonPhotoUrl())); | |||
| param.setVoice_id(voiceMouldSmId == null ? "default" : voiceMouldSmId); | |||
| param.setVoice_id(photoSpeakVideo.getVoiceMouldSm() == null ? "default" : photoSpeakVideo.getVoiceMouldSm()); | |||
| String voiceMouldSm = photoSpeakVideo.getVoiceMouldSm(); | |||
| Integer speakType = 0; | |||
| String voiceType = "default";//默认 | |||
| Integer sex = 1; | |||
| if (!StringUtils.isBlank(voiceMouldSm)) { | |||
| JSONObject jsonObject = JSON.parseObject(voiceMouldSm); | |||
| speakType = jsonObject.getInteger("speakType"); | |||
| Integer personType = jsonObject.getInteger("personType"); | |||
| sex = jsonObject.getInteger("sex"); | |||
| if(speakType != null && speakType > 0){ | |||
| voiceType = EnumSpeakType.getEnum(speakType).getMessage(); | |||
| }else if(personType != null && personType > 0){ | |||
| voiceType = EnumPersonType.getEnum(personType).getMessage(); | |||
| } | |||
| } | |||
| param.setVoice_style(EnumSpeakType.getEnum(speakType).getType()); | |||
| Integer voiceFrom = photoSpeakVideo.getVoiceFrom(); | |||
| String voiceMaterialUrl = photoSpeakVideo.getVoiceMaterialUrl(); | |||
| if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | |||
| param.setGen_txt(paperwork.replaceAll(str, "[*]")); | |||
| param.setGen_txt(photoSpeakVideo.getPaperwork().replaceAll(str, "[*]")); | |||
| if (sex == 1){ | |||
| param.setGender("male"); | |||
| }else if (sex == 2){ | |||
| @@ -396,48 +225,18 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
| AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||
| if (video.isSuccess()) { | |||
| videoUpd.setVideoPath(video.getUrl()); | |||
| videoUpd.setSaveDir(video.getSaveDir()); | |||
| videoUpd.setVideoStatus(EnumVideoStatus.success.getCode()); | |||
| videoUpd.setVideoMsg("success"); | |||
| videoUpd.setCreateVideoDate(new Date()); | |||
| this.saveOrUpdate(videoUpd); | |||
| videoUpd.setTitle(photoSpeakVideo.getTitle()); | |||
| // UserCreditLog log = new UserCreditLog(); | |||
| // log.setId(IdWorker.get().nextId()); | |||
| // log.setUserId(photoSpeakVideo.getUserId()); | |||
| // log.setCredits(-(float)useCredit); | |||
| // log.setType(EnumLogType.PHOTO_SPEAK.getCode()); | |||
| // log.setRemark(EnumLogType.PHOTO_SPEAK.getMessage()); | |||
| // log.setVideoOrPhotoOrTalkId(videoUpd.getId()); | |||
| // userCreditLogService.insertLog(log); | |||
| this.uploadVideo(videoUpd); | |||
| return new AsyncResult<>(1); | |||
| } | |||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| videoUpd.setVideoMsg(video.getMsg()); | |||
| this.saveOrUpdate(videoUpd); | |||
| if (flag) { | |||
| //如果生成视频失败了,就把创建视频积分加回去 | |||
| userCreateVideoNumService.addOrSubtractNumberOfTimes(2, videoNum, useCredit, videoTime); | |||
| return new ResultData(); | |||
| } | |||
| return new AsyncResult<>(0); | |||
| photoSpeakVideo.setVideoStatus(EnumVideoStatus.draft.getCode()); | |||
| photoSpeakVideo.setVideoMsg(video.getMsg()); | |||
| this.saveOrUpdate(photoSpeakVideo); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"接口请求异常"); | |||
| } catch (Exception e) { | |||
| if (flag) { | |||
| //如果生成视频失败了,就把创建视频积分加回去 | |||
| userCreateVideoNumService.addOrSubtractNumberOfTimes(2, videoNum, useCredit, videoTime); | |||
| } | |||
| e.printStackTrace(); | |||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
| videoUpd.setVideoMsg("请求异常"); | |||
| this.saveOrUpdate(videoUpd); | |||
| return new AsyncResult<>(0); | |||
| photoSpeakVideo.setVideoStatus(EnumVideoStatus.draft.getCode()); | |||
| photoSpeakVideo.setVideoMsg("第三方接口请求异常"); | |||
| this.saveOrUpdate(photoSpeakVideo); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"接口请求异常"); | |||
| } | |||
| } | |||
| @@ -19,6 +19,8 @@ public class AiPhotoSpeakResult { | |||
| return "没有检测到文本"; | |||
| } else if (code == 3008 && msg.equals("check languages")) { | |||
| return "文字和语种不对应"; | |||
| } else if (msg.equals("unknown error")) { | |||
| return "系统服务异常"; | |||
| } else { | |||
| return msg; | |||
| } | |||
| @@ -21,6 +21,8 @@ public class AiPreviewResult { | |||
| return "没有检测到文本"; | |||
| } else if (code == 3008 && msg.equals("check languages")) { | |||
| return "文字和语种不对应"; | |||
| } else if (msg.equals("unknown error")) { | |||
| return "系统服务异常"; | |||
| } else { | |||
| return msg; | |||
| } | |||
| @@ -12,6 +12,8 @@ public class AiVideoHqResult { | |||
| public String getMsgInfo(Integer code, String msg) { | |||
| if (code == 5000 && msg.equals("success")) { | |||
| return "成功"; | |||
| } else if (msg.equals("unknown error")) { | |||
| return "系统服务异常"; | |||
| } | |||
| return msg; | |||
| } | |||