# Conflicts: # suimangService/src/main/java/com/iformall/service/sm/impl/PhotoSpeakVideoServiceImpl.java # suimangService/src/main/java/com/iformall/sm/AiVideoHelper.javaprivate_deployment
| @@ -0,0 +1,2 @@ | |||||
| ALTER TABLE `mallink_suimang_test`.`photo_speak_video` | |||||
| ADD COLUMN `save_dir` varchar(255) NULL COMMENT '超分的视频路径' AFTER `music_id`; | |||||
| @@ -0,0 +1,14 @@ | |||||
| ALTER TABLE `mallink_suimang_test`.`photo_speak_video` | |||||
| ADD COLUMN `video_hy_status` smallint DEFAULT 0 NULL COMMENT '视频超分状态' AFTER `video_status`; | |||||
| ALTER TABLE `mallink_suimang_test`.`voice_info` | |||||
| ADD COLUMN `age_type` smallint NULL COMMENT '年纪类型 EnumAgeType' AFTER `sex`; | |||||
| ALTER TABLE `mallink_suimang_test`.`photo_speak_video` | |||||
| ADD COLUMN `is_hy` smallint NULL DEFAULT 0 COMMENT '是否超分(1、是,2、否)' AFTER `video_hy_status`, | |||||
| ALTER TABLE `mallink_suimang_test`.`voice_material` | |||||
| ADD COLUMN `time` double NULL COMMENT '视频时长' AFTER `type`; | |||||
| ALTER TABLE `mallink_suimang_test`.`photo_speak_video` | |||||
| ADD COLUMN `audio_path` varchar(255) NULL DEFAULT NULL COMMENT 'audio_path' AFTER `save_dir`, | |||||
| @@ -38,22 +38,29 @@ public class JsonImportController { | |||||
| @Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
| @PostMapping("/json") | @PostMapping("/json") | ||||
| public ResultData importMethod(@RequestBody List<JsonRootBean> list) { | |||||
| public ResultData importLanguage(@RequestBody List<JsonRootBean> list) { | |||||
| String str = "https://suimang.oss-accelerate.aliyuncs.com/builtin/country/"; | String str = "https://suimang.oss-accelerate.aliyuncs.com/builtin/country/"; | ||||
| HashSet<VoiceLanguage> set = new HashSet<>(); | HashSet<VoiceLanguage> set = new HashSet<>(); | ||||
| for (JsonRootBean bean : list) { | for (JsonRootBean bean : list) { | ||||
| VoiceLanguage language = new VoiceLanguage(); | VoiceLanguage language = new VoiceLanguage(); | ||||
| String[] split = bean.getLocale().split("-"); | String[] split = bean.getLocale().split("-"); | ||||
| language.setCountry(split[0]); | |||||
| language.setLanguage(split[1]); | |||||
| language.setImg(str + split[0] + ".png"); | |||||
| language.setCountry(split[1]); | |||||
| language.setLanguage(split[0]); | |||||
| language.setImg(str + split[1].toLowerCase() + ".png"); | |||||
| language.setLocal(bean.getLocale()); | language.setLocal(bean.getLocale()); | ||||
| language.setName(bean.getLocaleName()); | language.setName(bean.getLocaleName()); | ||||
| language.setIsDel(0); | language.setIsDel(0); | ||||
| HashMap<String, String> map = initNameMap(); | |||||
| language.setChineseName(map.get(bean.getLocale())); | |||||
| set.add(language); | set.add(language); | ||||
| } | } | ||||
| voiceLanguageMapper.saveBatch(set); | voiceLanguageMapper.saveBatch(set); | ||||
| return new ResultData("导入完成"); | |||||
| } | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| @PostMapping("/language") | |||||
| public ResultData importVoiceInfo(@RequestBody List<JsonRootBean> list) { | |||||
| List<VoiceInfo> list1 = new ArrayList<>(); | List<VoiceInfo> list1 = new ArrayList<>(); | ||||
| for (JsonRootBean bean : list) { | for (JsonRootBean bean : list) { | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| @@ -64,9 +71,9 @@ public class JsonImportController { | |||||
| voiceInfo.setId(voiceMould.getId()); | voiceInfo.setId(voiceMould.getId()); | ||||
| } | } | ||||
| VoiceLanguage voiceLanguage = voiceLanguageMapper.selectOne(new QueryWrapper<VoiceLanguage>().lambda().eq(VoiceLanguage::getLocal, bean.getLocale())); | VoiceLanguage voiceLanguage = voiceLanguageMapper.selectOne(new QueryWrapper<VoiceLanguage>().lambda().eq(VoiceLanguage::getLocal, bean.getLocale())); | ||||
| if (!ObjectUtils.isEmpty(voiceLanguage)) { | |||||
| if (voiceLanguage.getId() != null) { | |||||
| voiceInfo.setLanguageId(voiceLanguage.getId()); | voiceInfo.setLanguageId(voiceLanguage.getId()); | ||||
| }else { | |||||
| } else { | |||||
| System.out.println(bean.getName()); | System.out.println(bean.getName()); | ||||
| } | } | ||||
| String gender = bean.getGender(); | String gender = bean.getGender(); | ||||
| @@ -86,6 +93,13 @@ public class JsonImportController { | |||||
| if (!StringUtils.isEmpty(bean.getStyleList())) { | if (!StringUtils.isEmpty(bean.getStyleList())) { | ||||
| voiceInfo.setStyleList(JSON.toJSONString(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.setCreateDate(date); | ||||
| voiceInfo.setUpdateDate(date); | voiceInfo.setUpdateDate(date); | ||||
| list1.add(voiceInfo); | list1.add(voiceInfo); | ||||
| @@ -93,4 +107,220 @@ public class JsonImportController { | |||||
| voiceMapper.saveBatch(list1); | voiceMapper.saveBatch(list1); | ||||
| return new ResultData("导入完成"); | 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; | |||||
| } | |||||
| } | |||||
| @@ -5,14 +5,13 @@ import com.iformall.annotation.AuthIgnore; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.po.sm.MaterialMould; | |||||
| import com.iformall.domain.po.sm.PersonPhoto; | import com.iformall.domain.po.sm.PersonPhoto; | ||||
| import com.iformall.enums.EnumMouldPatchType; | |||||
| import com.iformall.enums.EnumMouldSendType; | import com.iformall.enums.EnumMouldSendType; | ||||
| import com.iformall.enums.EnumaMouldPatchStatus; | import com.iformall.enums.EnumaMouldPatchStatus; | ||||
| 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.AiBaiduCheckResult; | |||||
| import com.iformall.utils.BaiduImageCheckUtil; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -23,6 +22,7 @@ import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.util.ObjectUtils; | import org.springframework.util.ObjectUtils; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| @RestController | @RestController | ||||
| @@ -86,18 +86,30 @@ public class PersonPhotoController extends BaseController { | |||||
| } | } | ||||
| @ApiOperation("图片质量审核接口") | @ApiOperation("图片质量审核接口") | ||||
| @PostMapping("checkPhoto") | |||||
| @ApiImplicitParam(name = "material", value = "material", dataType = "String", paramType = "query", required = true) | |||||
| public ResultData checkPhoto(String material) { | |||||
| @PostMapping(value = "checkPhoto", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||||
| @ApiImplicitParam(name = "file", value = "file", dataType = "MultipartFile", paramType = "query", required = true) | |||||
| public ResultData checkPhoto(@RequestPart("file") MultipartFile file) { | |||||
| logger.debug("[" + getIpAddr() + "] PersonPhotoController::checkPhoto"); | logger.debug("[" + getIpAddr() + "] PersonPhotoController::checkPhoto"); | ||||
| if (StringUtils.isBlank(material)) { | |||||
| if (ObjectUtils.isEmpty(file) || file.getSize() <= 0) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "素材为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "素材为空"); | ||||
| } | } | ||||
| ResultData data = personPhotoService.checkPhoto(material); | |||||
| if (data.code == 2000) { | |||||
| return new ResultData(); | |||||
| return personPhotoService.checkPhoto(file); | |||||
| } | |||||
| @ApiOperation("百度图片审核接口") | |||||
| @PostMapping(value = "baiduPhoto", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||||
| @ApiImplicitParam(name = "file", value = "file", dataType = "MultipartFile", paramType = "query", required = true) | |||||
| public ResultData baiduCheckPhoto(@RequestPart("file") MultipartFile file) { | |||||
| logger.debug("[" + getIpAddr() + "] PersonPhotoController::baiduCheckPhoto"); | |||||
| if (ObjectUtils.isEmpty(file) || file.getSize() <= 0) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "素材为空"); | |||||
| } | |||||
| long size = file.getSize(); | |||||
| final long length = 4 * 1024 * 1024; | |||||
| if (size > length) { | |||||
| return new ResultData(ErrorCode.PICTURE_FOUR_SIZE_EXCEED); | |||||
| } | } | ||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), data.message); | |||||
| return BaiduImageCheckUtil.photoCheck(file); | |||||
| } | } | ||||
| @@ -7,9 +7,7 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import com.iformall.domain.po.sm.*; | 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.exception.MallinkException; | ||||
| import com.iformall.service.sm.*; | import com.iformall.service.sm.*; | ||||
| import com.iformall.video.VideoFactory; | import com.iformall.video.VideoFactory; | ||||
| @@ -24,6 +22,8 @@ import org.checkerframework.checker.units.qual.A; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | 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 org.springframework.web.bind.annotation.*; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| @@ -178,6 +178,67 @@ public class PhotoSpeakVideoController extends BaseController { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"视频已生成完成"); | return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"视频已生成完成"); | ||||
| } | } | ||||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | |||||
| videoUpd.setId(record.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(); | |||||
| } | |||||
| if(StringUtils.isBlank(voiceMaterialUrl)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到上传声音文件"); | |||||
| } | |||||
| videoUpd.setVoiceMaterialUrl(voiceMaterialUrl); | |||||
| // 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(); | PhotoSpeakVideo mouldVideoUpd = new PhotoSpeakVideo(); | ||||
| mouldVideoUpd.setId(record.getId()); | mouldVideoUpd.setId(record.getId()); | ||||
| mouldVideoUpd.setVideoStatus(EnumVideoStatus.ing.getCode()); | mouldVideoUpd.setVideoStatus(EnumVideoStatus.ing.getCode()); | ||||
| @@ -185,7 +246,7 @@ public class PhotoSpeakVideoController extends BaseController { | |||||
| mouldVideoUpd.setCreateVideoDate(new Date()); | mouldVideoUpd.setCreateVideoDate(new Date()); | ||||
| photoSpeakVideoService.saveOrUpdate(mouldVideoUpd); | photoSpeakVideoService.saveOrUpdate(mouldVideoUpd); | ||||
| photoSpeakVideoService.createVideo(mouldVideo,true); | |||||
| photoSpeakVideoService.createVideo(videoUpd); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -363,4 +424,54 @@ public class PhotoSpeakVideoController extends BaseController { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @ApiOperation("视频超分") | |||||
| @GetMapping("/videoHy") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData videoHy(Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] PersonPhotoController::videoHy"); | |||||
| if(id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"参数为空"); | |||||
| } | |||||
| PhotoSpeakVideo speakVideo = photoSpeakVideoService.getById(id); | |||||
| if(speakVideo == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到数据"); | |||||
| } | |||||
| if (StringUtils.isEmpty(speakVideo.getSaveDir())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"save_dir为空"); | |||||
| } | |||||
| if(!speakVideo.getUserId().equals(getMemberId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"未找到用户数据"); | |||||
| } | |||||
| if(!EnumVideoStatus.upload_success.getCode().equals(speakVideo.getVideoStatus())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"原始视频生成未完成"); | |||||
| } | |||||
| if(EnumVideoStatus.ing.getCode().equals(speakVideo.getVideoHyStatus()) | |||||
| || EnumVideoStatus.success.getCode().equals(speakVideo.getVideoHyStatus()) | |||||
| || EnumVideoStatus.upload_ing.getCode().equals(speakVideo.getVideoHyStatus()) | |||||
| || EnumVideoStatus.upload_fail.getCode().equals(speakVideo.getVideoHyStatus())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"高清晰度视频生成中"); | |||||
| } | |||||
| if(EnumVideoStatus.upload_success.getCode().equals(speakVideo.getVideoHyStatus())){ | |||||
| //上传阿里云状态 生成成功 | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"高清晰度视频已生成完成"); | |||||
| } | |||||
| speakVideo.setVideoHyStatus(EnumVideoStatus.ing.getCode()); | |||||
| speakVideo.setVideoMsg(""); | |||||
| speakVideo.setIsHy(EnumYesOrNo.YES.getCode()); | |||||
| speakVideo.setUpdateDate(new Date()); | |||||
| photoSpeakVideoService.updateById(speakVideo); | |||||
| photoSpeakVideoService.videoHy(speakVideo); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("获取视频是否生成成功") | |||||
| @GetMapping("/checkVideoStatus") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData checkVideoStatus(@RequestParam("list") List<Long> list,@RequestParam("type") Integer type) { | |||||
| return photoSpeakVideoService.checkVideoStatus(getMemberId(),list,type); | |||||
| } | |||||
| } | } | ||||
| @@ -17,10 +17,9 @@ import org.apache.commons.lang3.StringUtils; | |||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | |||||
| import org.springframework.web.bind.annotation.RequestBody; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import org.springframework.util.ObjectUtils; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| @@ -43,12 +42,12 @@ public class SDKController extends BaseController { | |||||
| @ApiOperation("图片质量审核接口") | @ApiOperation("图片质量审核接口") | ||||
| @PostMapping("checkPhoto") | @PostMapping("checkPhoto") | ||||
| @ApiImplicitParam(name = "material", value = "material", dataType = "String", paramType = "query", required = true) | @ApiImplicitParam(name = "material", value = "material", dataType = "String", paramType = "query", required = true) | ||||
| public ResultData checkPhoto(String material) { | |||||
| public ResultData checkPhoto(@RequestPart("file") MultipartFile file) { | |||||
| logger.debug("[" + getIpAddr() + "] SDKController::checkPhoto"); | logger.debug("[" + getIpAddr() + "] SDKController::checkPhoto"); | ||||
| if (StringUtils.isBlank(material)) { | |||||
| if (ObjectUtils.isEmpty(file) || file.getSize() <= 0) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "素材为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "素材为空"); | ||||
| } | } | ||||
| ResultData data = personPhotoService.checkPhoto(material); | |||||
| ResultData data = personPhotoService.checkPhoto(file); | |||||
| if (data.code == 2000) { | if (data.code == 2000) { | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @@ -101,7 +100,7 @@ public class SDKController extends BaseController { | |||||
| mouldVideoUpd.setVideoMsg(""); | mouldVideoUpd.setVideoMsg(""); | ||||
| mouldVideoUpd.setCreateVideoDate(new Date()); | mouldVideoUpd.setCreateVideoDate(new Date()); | ||||
| photoSpeakVideoService.saveOrUpdate(mouldVideoUpd); | photoSpeakVideoService.saveOrUpdate(mouldVideoUpd); | ||||
| photoSpeakVideoService.createVideo(mouldVideo, true); | |||||
| photoSpeakVideoService.createVideo(mouldVideo); | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -75,9 +75,9 @@ public class UploadController extends BaseController { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | TenantEntity tenantEntity = getTenantInfo(); | ||||
| long size = multiReq.getSize(); | long size = multiReq.getSize(); | ||||
| final long length = 2097152; | |||||
| final long length = 2097152 * 2; | |||||
| if (size > length) { | if (size > length) { | ||||
| return new ResultData(ErrorCode.PICTURE_SIZE_EXCEED); | |||||
| return new ResultData(ErrorCode.PICTURE_FOUR_SIZE_EXCEED); | |||||
| } | } | ||||
| String fileFormat = ""; | String fileFormat = ""; | ||||
| @@ -0,0 +1,126 @@ | |||||
| package com.iformall.controller; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.baomidou.mybatisplus.extension.api.R; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.annotation.AuthIgnore; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.base.BaseEntity; | |||||
| import com.iformall.domain.po.sm.MusicInfo; | |||||
| import com.iformall.domain.po.sm.PhotoSpeakVideo; | |||||
| import com.iformall.domain.po.sm.VoiceInfo; | |||||
| import com.iformall.enums.EnumVideoStatus; | |||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.sm.MouldPatchService; | |||||
| import com.iformall.service.sm.MusicInfoService; | |||||
| import com.iformall.service.sm.PhotoSpeakVideoService; | |||||
| import com.iformall.service.sm.VoiceInfoService; | |||||
| import com.iformall.video.VideoFactory; | |||||
| import com.iformall.video.aliyun.sdk.server.UploadCacheHelper; | |||||
| import com.iformall.video.entity.VideUploadResult; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import lombok.SneakyThrows; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.flowable.idm.engine.impl.persistence.entity.UserEntity; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import javax.servlet.http.HttpServletResponse; | |||||
| import java.io.File; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.io.OutputStream; | |||||
| import java.net.URL; | |||||
| import java.net.URLEncoder; | |||||
| import java.nio.charset.StandardCharsets; | |||||
| import java.util.*; | |||||
| @RestController | |||||
| @RequestMapping("/callback") | |||||
| @Api(description = "视频回调") | |||||
| public class VideoCallbackController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private PhotoSpeakVideoService photoSpeakVideoService; | |||||
| @AuthIgnore | |||||
| @ApiOperation("视频回调") | |||||
| @PostMapping(value = "/photo/speak") | |||||
| public ResultData photoSpeak(@RequestBody Map<String, Object> paranMap) { | |||||
| logger.debug("[" + getIpAddr() + "] VideoCallbackController::photoSpeak"); | |||||
| logger.info("照片生成视频结果通知{}"+JSONObject.toJSONString(paranMap)); | |||||
| Long task_id = (Long) paranMap.get("task_id");//任务ID | |||||
| String code = (String) paranMap.get("code");//code | |||||
| String msg = (String) paranMap.get("msg"); | |||||
| Object data = paranMap.get("data"); | |||||
| String jsonString = JSONObject.toJSONString(data); | |||||
| Map dataMap = JSONObject.parseObject(jsonString,Map.class); | |||||
| Boolean sr = (Boolean) dataMap.get("sr");//判断 sr=True 就是超分的, False 是没超分的 | |||||
| String url = (String) dataMap.get("url"); | |||||
| String save_dir = null; | |||||
| if (!sr){ | |||||
| save_dir = (String) dataMap.get("save_dir"); | |||||
| } | |||||
| if (task_id == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"任务ID不能为空"); | |||||
| } | |||||
| PhotoSpeakVideo photoSpeakVideo = photoSpeakVideoService.getById(Long.valueOf(task_id)); | |||||
| if (photoSpeakVideo == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到任务数据"); | |||||
| } | |||||
| if (Integer.parseInt(code) != 4000){ | |||||
| String returnMsg; | |||||
| if (sr){ | |||||
| photoSpeakVideo.setVideoHyStatus(EnumVideoStatus.fail.getCode()); | |||||
| returnMsg = "超分视频生成失败"; | |||||
| }else { | |||||
| photoSpeakVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| returnMsg = "视频生成失败"; | |||||
| } | |||||
| photoSpeakVideo.setVideoMsg("(MetaService)"+msg); | |||||
| photoSpeakVideo.setUpdateDate(new Date()); | |||||
| photoSpeakVideoService.updateById(photoSpeakVideo); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),returnMsg); | |||||
| } | |||||
| if (StringUtils.isEmpty(url)){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"视频URL不能为空"); | |||||
| } | |||||
| if (save_dir != null && !save_dir.equals(photoSpeakVideo.getSaveDir())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"save_dir参数不一致"); | |||||
| } | |||||
| if (sr){ | |||||
| photoSpeakVideo.setVideoHyStatus(EnumVideoStatus.success.getCode()); | |||||
| }else { | |||||
| photoSpeakVideo.setVideoStatus(EnumVideoStatus.success.getCode()); | |||||
| } | |||||
| photoSpeakVideo.setVideoMsg("success"); | |||||
| photoSpeakVideo.setUpdateDate(new Date()); | |||||
| photoSpeakVideoService.updateById(photoSpeakVideo); | |||||
| //TODO 用户相关操作 | |||||
| if (sr){ | |||||
| photoSpeakVideoService.uploadHyVideo(photoSpeakVideo); | |||||
| }else { | |||||
| photoSpeakVideoService.uploadVideo(photoSpeakVideo); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,77 @@ | |||||
| package com.iformall.utils; | |||||
| import java.io.BufferedReader; | |||||
| import java.io.DataOutputStream; | |||||
| import java.io.InputStreamReader; | |||||
| import java.net.HttpURLConnection; | |||||
| import java.net.URL; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * http 工具类 | |||||
| */ | |||||
| public class BaiDuHttpUtil { | |||||
| public static String post(String requestUrl, String accessToken, String params) | |||||
| throws Exception { | |||||
| String contentType = "application/x-www-form-urlencoded"; | |||||
| return BaiDuHttpUtil.post(requestUrl, accessToken, contentType, params); | |||||
| } | |||||
| public static String post(String requestUrl, String accessToken, String contentType, String params) | |||||
| throws Exception { | |||||
| String encoding = "UTF-8"; | |||||
| if (requestUrl.contains("nlp")) { | |||||
| encoding = "GBK"; | |||||
| } | |||||
| return BaiDuHttpUtil.post(requestUrl, accessToken, contentType, params, encoding); | |||||
| } | |||||
| public static String post(String requestUrl, String accessToken, String contentType, String params, String encoding) | |||||
| throws Exception { | |||||
| String url = requestUrl + "?access_token=" + accessToken; | |||||
| return BaiDuHttpUtil.postGeneralUrl(url, contentType, params, encoding); | |||||
| } | |||||
| public static String postGeneralUrl(String generalUrl, String contentType, String params, String encoding) | |||||
| throws Exception { | |||||
| URL url = new URL(generalUrl); | |||||
| // 打开和URL之间的连接 | |||||
| HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | |||||
| connection.setRequestMethod("POST"); | |||||
| // 设置通用的请求属性 | |||||
| connection.setRequestProperty("Content-Type", contentType); | |||||
| connection.setRequestProperty("Connection", "Keep-Alive"); | |||||
| connection.setUseCaches(false); | |||||
| connection.setDoOutput(true); | |||||
| connection.setDoInput(true); | |||||
| // 得到请求的输出流对象 | |||||
| DataOutputStream out = new DataOutputStream(connection.getOutputStream()); | |||||
| out.write(params.getBytes(encoding)); | |||||
| out.flush(); | |||||
| out.close(); | |||||
| // 建立实际的连接 | |||||
| connection.connect(); | |||||
| // 获取所有响应头字段 | |||||
| Map<String, List<String>> headers = connection.getHeaderFields(); | |||||
| // 遍历所有的响应头字段 | |||||
| for (String key : headers.keySet()) { | |||||
| System.err.println(key + "--->" + headers.get(key)); | |||||
| } | |||||
| // 定义 BufferedReader输入流来读取URL的响应 | |||||
| BufferedReader in = null; | |||||
| in = new BufferedReader( | |||||
| new InputStreamReader(connection.getInputStream(), encoding)); | |||||
| String result = ""; | |||||
| String getLine; | |||||
| while ((getLine = in.readLine()) != null) { | |||||
| result += getLine; | |||||
| } | |||||
| in.close(); | |||||
| System.err.println("result:" + result); | |||||
| return result; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,114 @@ | |||||
| package com.iformall.utils; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.sm.AiBaiduCheckResult; | |||||
| import okhttp3.*; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import java.io.*; | |||||
| import java.net.URLEncoder; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.net.URL; | |||||
| import java.net.URLConnection; | |||||
| /** | |||||
| * 图片质量检查方法 | |||||
| */ | |||||
| public class BaiduImageCheckUtil { | |||||
| // 百度图片审核接口地址 | |||||
| private final static String photo_check_url = "https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined"; | |||||
| // 获取token | |||||
| private final static String auth_url = "https://aip.baidubce.com/oauth/2.0/token?"; | |||||
| // 百度API Key | |||||
| private final static String apiKey = "Your API Key"; | |||||
| // 百度Secret Key | |||||
| private final static String secretKey = "Your Secret Key"; | |||||
| //写死的 access_token | |||||
| private final static String access_token = "24.c1c7992795301773c60c8cf01abfe759.2592000.1689236723.282335-33618414"; | |||||
| public static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder().build(); | |||||
| public static ResultData photoCheck(MultipartFile file) { | |||||
| try { | |||||
| byte[] fileBytes = file.getBytes(); | |||||
| String imgStr = Base64Util.encode(fileBytes); | |||||
| String imageUrl = URLEncoder.encode(imgStr, "UTF-8"); | |||||
| String param = "image=" + imageUrl; | |||||
| // 注意这里access_token有过期时间, 客户端可自行缓存,过期后重新获取。 | |||||
| // Access Token的有效期(秒为单位,有效期30天) | |||||
| // String accessToken = getAuth(); | |||||
| //这里暂时写死 | |||||
| String result = BaiDuHttpUtil.post(photo_check_url, access_token, param); | |||||
| System.out.println(result); | |||||
| JSONObject jsonObject = JSON.parseObject(result); | |||||
| //1:合规,2:不合规,3:疑似,4:审核失败 | |||||
| Integer type = jsonObject.getInteger("conclusionType"); | |||||
| if (type == 1) { | |||||
| return new ResultData(); | |||||
| } else if (type == 2 || type == 3) { | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"图片不合规"); | |||||
| } else if (type == 4) { | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"图片审核失败"); | |||||
| } else { | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"图片不合规"); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"图片审核失败"); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 将阿里云图片地址转为字节码 | |||||
| */ | |||||
| public static String aliyunImageToByteArray(String imageUrl) throws IOException { | |||||
| InputStream inputStream = null; | |||||
| try { | |||||
| // 创建URL对象 | |||||
| URL url = new URL(imageUrl); | |||||
| // 打开连接 | |||||
| URLConnection conn = url.openConnection(); | |||||
| // 获取输入流 | |||||
| inputStream = conn.getInputStream(); | |||||
| // 将输入流转换为字节数组 | |||||
| ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); | |||||
| byte[] buffer = new byte[4096]; | |||||
| int bytesRead; | |||||
| while ((bytesRead = inputStream.read(buffer)) != -1) { | |||||
| byteStream.write(buffer, 0, bytesRead); | |||||
| } | |||||
| inputStream.close(); | |||||
| byte[] byteArray = byteStream.toByteArray(); | |||||
| String imgStr = Base64Util.encode(byteArray); | |||||
| return URLEncoder.encode(imgStr, "UTF-8"); | |||||
| } catch (IOException e) { | |||||
| e.printStackTrace(); | |||||
| if (inputStream != null) { | |||||
| inputStream.close(); | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * 获取API访问权限token,该token有一定的有效期,需要自行管理,当失效时需重新获取。 | |||||
| * Access Token的有效期(秒为单位,有效期30天) | |||||
| */ | |||||
| public static String getAuth() throws IOException { | |||||
| MediaType mediaType = MediaType.parse("application/json"); | |||||
| RequestBody body = RequestBody.create(mediaType, ""); | |||||
| Request request = new Request.Builder() | |||||
| .url(auth_url + "client_id=" + apiKey + "&client_secret= " + secretKey + "&grant_type=client_credentials") | |||||
| .method("POST", body) | |||||
| .addHeader("Content-Type", "application/json") | |||||
| .addHeader("Accept", "application/json") | |||||
| .build(); | |||||
| Response response = HTTP_CLIENT.newCall(request).execute(); | |||||
| System.out.println(response.body().string()); | |||||
| return response.body().string(); | |||||
| } | |||||
| } | |||||
| @@ -10,7 +10,9 @@ public class UrlCheck { | |||||
| || url.contains("awsFilesUpload") | || url.contains("awsFilesUpload") | ||||
| || url.contains("awsImgUpload") | || url.contains("awsImgUpload") | ||||
| || url.contains("getCarStopFee") | || url.contains("getCarStopFee") | ||||
| || url.contains("/video/upload"); | |||||
| || url.contains("/video/upload") | |||||
| || url.contains("/personPhoto/baiduPhoto") | |||||
| || url.contains("/personPhoto/checkPhoto"); | |||||
| } | } | ||||
| } | } | ||||
| @@ -186,4 +186,10 @@ fm: | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| com.iformall: debug | com.iformall: debug | ||||
| path: ./logs/c | |||||
| path: ./logs/c | |||||
| photo: | |||||
| url: http://nas.pucao.cn:2002 | |||||
| hy_url: http://nas.pucao.cn:2002 | |||||
| talk: | |||||
| callbackUrl: https://phototest.metavatar.cc/C | |||||
| @@ -141,4 +141,10 @@ fm: | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| com.iformall: debug | com.iformall: debug | ||||
| path: ./logs/c | |||||
| path: ./logs/c | |||||
| photo: | |||||
| url: http://111.198.0.15:22299 | |||||
| hy_url: http://111.198.0.15:22288 | |||||
| talk: | |||||
| callbackUrl: https://photo.metavatar.cc/C | |||||
| @@ -57,8 +57,7 @@ public class PhotoSpeakSchedule { | |||||
| if (list != null && list.size() > 0) { | if (list != null && list.size() > 0) { | ||||
| for (PhotoSpeakVideo video : list) { | for (PhotoSpeakVideo video : list) { | ||||
| try { | try { | ||||
| Future future = photoSpeakVideoService.createVideo(video,false); | |||||
| future.get(); | |||||
| photoSpeakVideoService.createVideo(video); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); | logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); | ||||
| } | } | ||||
| @@ -109,4 +108,68 @@ public class PhotoSpeakSchedule { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * 超分上传阿里云 | |||||
| */ | |||||
| @Scheduled(cron = "0 */30 * * * *?") // 每半小时检查一次 | |||||
| public void userVideoHyUploadSchedule() { | |||||
| List<PhotoSpeakVideo> videos = photoSpeakVideoService.getNotHyUploadList(); | |||||
| if (videos != null && videos.size() > 0) { | |||||
| for (PhotoSpeakVideo video : videos) { | |||||
| try { | |||||
| photoSpeakVideoService.uploadHyVideo(video); | |||||
| } catch (Exception e) { | |||||
| logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 获取超分时长和大小 | |||||
| */ | |||||
| @Scheduled(cron = "0 1/5 * * * *?") // 每五分钟检查一次 | |||||
| public void userVideoHyDetailSchedule() { | |||||
| List<PhotoSpeakVideo> videos = photoSpeakVideoService.getUpLoadHyIngList(); | |||||
| if (videos != null && videos.size() > 0) { | |||||
| for (PhotoSpeakVideo video : videos) { | |||||
| try { | |||||
| VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(video.getVideoId()); | |||||
| if (videoDetail.isSuccess() | |||||
| && StringUtils.isNotBlank(videoDetail.getDuration()) | |||||
| && !"0.0".equals(videoDetail.getDuration())) { | |||||
| video.setCoverImg(videoDetail.getCoverURL()); | |||||
| video.setVideoPlayUrl(videoDetail.getVideoUrl()); | |||||
| video.setVideoTime(videoDetail.getDuration()); | |||||
| video.setVideoSize(videoDetail.getSize()); | |||||
| video.setVideoHyStatus(EnumVideoStatus.upload_success.getCode()); | |||||
| photoSpeakVideoService.updateById(video); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 超分生成视频 | |||||
| */ | |||||
| @Scheduled(cron = "0 20/30 * * * *?") // 每半小时检查一次 | |||||
| public void photoSpeakCreateHySchedule() { | |||||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | |||||
| videoUpd.setVideoStartDate(DateUtils.getHourDateBefore(2,new Date())); | |||||
| videoUpd.setVideoHyStatus(EnumVideoStatus.fail.getCode()); | |||||
| List<PhotoSpeakVideo> list = photoSpeakVideoService.findList(videoUpd); | |||||
| if (list != null && list.size() > 0) { | |||||
| for (PhotoSpeakVideo video : list) { | |||||
| try { | |||||
| photoSpeakVideoService.videoHy(video); | |||||
| } catch (Exception e) { | |||||
| logger.error("TtCouponVideoSchedule error.couponVideoSchedule:"+video.getId(),e); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -190,3 +190,9 @@ logging: | |||||
| #tk.mybatis: debug | #tk.mybatis: debug | ||||
| com.iformall.mapper: debug | com.iformall.mapper: debug | ||||
| path: ./logs/s | path: ./logs/s | ||||
| photo: | |||||
| url: http://nas.pucao.cn:2002 | |||||
| hy_url: http://nas.pucao.cn:2002 | |||||
| talk: | |||||
| callbackUrl: https://phototest.metavatar.cc/C | |||||
| @@ -144,4 +144,11 @@ logging: | |||||
| level: | level: | ||||
| #tk.mybatis: debug | #tk.mybatis: debug | ||||
| com.iformall: debug | com.iformall: debug | ||||
| path: ./logs/s | |||||
| path: ./logs/s | |||||
| photo: | |||||
| url: http://111.198.0.15:22299 | |||||
| hy_url: http://111.198.0.15:22288 | |||||
| talk: | |||||
| callbackUrl: https://photo.metavatar.cc/C | |||||
| @@ -103,6 +103,7 @@ public enum ErrorCode{ | |||||
| MEMBER_IS_NOT_ACTIVE(2112, "当前会员未激活"), | MEMBER_IS_NOT_ACTIVE(2112, "当前会员未激活"), | ||||
| MEMBER_IS_ACTIVE(2113, "当前会员已激活"), | MEMBER_IS_ACTIVE(2113, "当前会员已激活"), | ||||
| MEMBER_IS_FOUND(2114, "当前会员已存在"), | MEMBER_IS_FOUND(2114, "当前会员已存在"), | ||||
| VIDEO_CREATING(2115, "视频生成中"), | |||||
| /** | /** | ||||
| * 商场/商户 | * 商场/商户 | ||||
| @@ -609,6 +610,7 @@ public enum ErrorCode{ | |||||
| PICTURE_SIZE_CUSTOMIZE(40003, "图片超过大小限制"), | PICTURE_SIZE_CUSTOMIZE(40003, "图片超过大小限制"), | ||||
| PICTURE_W_H_CUSTOMIZE(40004, "图片不符合宽高限制"), | PICTURE_W_H_CUSTOMIZE(40004, "图片不符合宽高限制"), | ||||
| PICTURE_ENDWIDTH_ERROR(40005, "格式只支持.mp3,.mp4"), | PICTURE_ENDWIDTH_ERROR(40005, "格式只支持.mp3,.mp4"), | ||||
| PICTURE_FOUR_SIZE_EXCEED(40006, "图片超过4M限制"), | |||||
| /** | /** | ||||
| * 电费生成配置 | * 电费生成配置 | ||||
| @@ -1,114 +1,35 @@ | |||||
| package com.iformall.domain.po.json; | package com.iformall.domain.po.json; | ||||
| import com.fasterxml.jackson.annotation.JsonProperty; | |||||
| import lombok.Data; | |||||
| import java.util.List; | import java.util.List; | ||||
| @Data | |||||
| public class JsonRootBean { | 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; | |||||
| } | |||||
| } | } | ||||
| @@ -122,12 +122,12 @@ public class PhotoSpeakVideo extends TenantEntity { | |||||
| } | } | ||||
| return videoPathUri; | return videoPathUri; | ||||
| } | } | ||||
| public String getPhotoSpeakPathUri(){ | |||||
| if(StringUtils.isNotBlank(this.videoPath)){ | |||||
| videoPathUri = AiVideoHelper.url; | |||||
| } | |||||
| return videoPathUri; | |||||
| } | |||||
| // public String getPhotoSpeakPathUri(){ | |||||
| // if(StringUtils.isNotBlank(this.videoPath)){ | |||||
| // videoPathUri = AiVideoHelper.url; | |||||
| // } | |||||
| // return videoPathUri; | |||||
| // } | |||||
| @io.swagger.annotations.ApiModelProperty(value="",name="videoPath") | @io.swagger.annotations.ApiModelProperty(value="",name="videoPath") | ||||
| private String videoPath; | private String videoPath; | ||||
| @io.swagger.annotations.ApiModelProperty(value="播放地址",name="videoPlayUrl") | @io.swagger.annotations.ApiModelProperty(value="播放地址",name="videoPlayUrl") | ||||
| @@ -151,6 +151,14 @@ public class PhotoSpeakVideo extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<Integer> videoStatuss; | private List<Integer> videoStatuss; | ||||
| private String audioPath; | |||||
| private Long musicId; | private Long musicId; | ||||
| private String saveDir; | |||||
| private Integer videoHyStatus; | |||||
| private Integer isHy;//是否超分(1、是,0、否) | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ package com.iformall.domain.po.sm; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.VoiceInfoVo; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -60,7 +61,7 @@ public class VoiceInfo extends TenantEntity { | |||||
| */ | */ | ||||
| private String styleList; | private String styleList; | ||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private List<String> style; | |||||
| private List<VoiceInfoVo> style; | |||||
| /** | /** | ||||
| * 创建时间 | * 创建时间 | ||||
| */ | */ | ||||
| @@ -73,4 +74,10 @@ public class VoiceInfo extends TenantEntity { | |||||
| * 是否删除1是0否 | * 是否删除1是0否 | ||||
| */ | */ | ||||
| private Integer isDel; | private Integer isDel; | ||||
| /** | |||||
| * 年纪类型 EnumAgeType | |||||
| */ | |||||
| private Integer ageType; | |||||
| @TableField(exist = false) | |||||
| private String voiceUrl; | |||||
| } | } | ||||
| @@ -121,4 +121,6 @@ public class VoiceMaterial extends TenantEntity { | |||||
| private Integer type; | private Integer type; | ||||
| private Double time; | |||||
| } | } | ||||
| @@ -0,0 +1,10 @@ | |||||
| package com.iformall.domain.vo; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class VoiceInfoVo { | |||||
| private String url; | |||||
| private String name; | |||||
| } | |||||
| @@ -16,7 +16,6 @@ public enum EnumVideoStatus { | |||||
| upload_ing(4,"上传视频中"), | upload_ing(4,"上传视频中"), | ||||
| upload_success(5,"上传视频成功"), | upload_success(5,"上传视频成功"), | ||||
| upload_fail(6,"上传视频失败") | upload_fail(6,"上传视频失败") | ||||
| ; | ; | ||||
| public static EnumVideoStatus getEnum(Integer code) { | public static EnumVideoStatus getEnum(Integer code) { | ||||
| @@ -23,4 +23,5 @@ public interface PhotoSpeakVideoMapper extends CommonMapper<PhotoSpeakVideo, Lon | |||||
| List<PhotoSpeakVideo> getSortList(PhotoSpeakVideo record); | List<PhotoSpeakVideo> getSortList(PhotoSpeakVideo record); | ||||
| Integer checkVideoStatus(@Param("userId") Long userId, @Param("list") List<Long> list,@Param("type") Integer type); | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.sm.MaterialMould; | import com.iformall.domain.po.sm.MaterialMould; | ||||
| import com.iformall.domain.po.sm.PersonPhoto; | import com.iformall.domain.po.sm.PersonPhoto; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| public interface PersonPhotoService { | public interface PersonPhotoService { | ||||
| @@ -43,5 +44,5 @@ public interface PersonPhotoService { | |||||
| void updateOnline(PersonPhoto record); | void updateOnline(PersonPhoto record); | ||||
| ResultData checkPhoto(String material); | |||||
| ResultData checkPhoto(MultipartFile file); | |||||
| } | } | ||||
| @@ -3,10 +3,8 @@ package com.iformall.service.sm; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.sm.PhotoSpeakVideo; | import com.iformall.domain.po.sm.PhotoSpeakVideo; | ||||
| import com.iformall.domain.po.sm.UserMouldVideo; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.concurrent.Future; | |||||
| public interface PhotoSpeakVideoService { | public interface PhotoSpeakVideoService { | ||||
| @@ -45,7 +43,7 @@ public interface PhotoSpeakVideoService { | |||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| Future createVideo(PhotoSpeakVideo mouldVideo,Boolean flag); | |||||
| ResultData createVideo(PhotoSpeakVideo mouldVideo); | |||||
| void uploadVideo(PhotoSpeakVideo mouldVideo); | void uploadVideo(PhotoSpeakVideo mouldVideo); | ||||
| @@ -59,4 +57,13 @@ public interface PhotoSpeakVideoService { | |||||
| int updateById(PhotoSpeakVideo video); | int updateById(PhotoSpeakVideo video); | ||||
| ResultData videoHy(PhotoSpeakVideo speakVideo); | |||||
| void uploadHyVideo(PhotoSpeakVideo mouldVideo); | |||||
| List<PhotoSpeakVideo> getUpLoadHyIngList(); | |||||
| List<PhotoSpeakVideo> getNotHyUploadList(); | |||||
| ResultData checkVideoStatus(Long userId, List<Long> time, Integer type); | |||||
| } | } | ||||
| @@ -29,8 +29,11 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import java.io.IOException; | |||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.net.URLEncoder; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -135,13 +138,20 @@ public class PersonPhotoServiceImpl implements PersonPhotoService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public ResultData checkPhoto(String material) { | |||||
| AiCheckPhotoParam param = new AiCheckPhotoParam(); | |||||
| param.setImg(Base64Util.imageUrlToBase64(material)); | |||||
| AiCheckPhotoResult result = AiVideoHelper.checkPhoto(param); | |||||
| if (result.isSuccess()){ | |||||
| return new ResultData(); | |||||
| public ResultData checkPhoto(MultipartFile file) { | |||||
| try { | |||||
| byte[] fileBytes = file.getBytes(); | |||||
| String imgStr = Base64Util.encode(fileBytes); | |||||
| AiCheckPhotoParam param = new AiCheckPhotoParam(); | |||||
| param.setImg(imgStr); | |||||
| AiCheckPhotoResult result = AiVideoHelper.checkPhoto(param); | |||||
| if (result.isSuccess()) { | |||||
| return new ResultData(); | |||||
| } | |||||
| return new ResultData(result.getCode(), result.getMsgInfo(result.getCode(),result.getMsg())); | |||||
| } catch (IOException e) { | |||||
| e.printStackTrace(); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "接口请求异常"); | |||||
| } | } | ||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), result.getMsg()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -75,8 +75,22 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| @Autowired | @Autowired | ||||
| private UserCreditLogService userCreditLogService; | private UserCreditLogService userCreditLogService; | ||||
| @Autowired | |||||
| @Qualifier("objectCommonRedisTemplate") | |||||
| RedisTemplate<String, Object> redisTemplate; | |||||
| @Value("${photo.url}") | |||||
| private String url; | |||||
| @Value("${photo.hy_url}") | |||||
| private String hy_url; | |||||
| @Value("${photo.talk}") | |||||
| private String talk_url; | |||||
| private final static String str = "\uD83D\uDD57"; | private final static String str = "\uD83D\uDD57"; | ||||
| @Value("${photo.callbackUrl}") | |||||
| private String callbackUrl; | |||||
| @Override | @Override | ||||
| public PageInfo<PhotoSpeakVideo> listAsPage(PhotoSpeakVideo record, Integer pageIndex, Integer pageSize) { | public PageInfo<PhotoSpeakVideo> listAsPage(PhotoSpeakVideo record, Integer pageIndex, Integer pageSize) { | ||||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> photoSpeakVideoMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> photoSpeakVideoMapper.findList(record)); | ||||
| @@ -177,7 +191,6 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| photoSpeakVideoMapper.deleteById(id); | photoSpeakVideoMapper.deleteById(id); | ||||
| } | } | ||||
| @Async | |||||
| @Override | @Override | ||||
| public Future createVideo(PhotoSpeakVideo photoSpeakVideo,Boolean flag) { | public Future createVideo(PhotoSpeakVideo photoSpeakVideo,Boolean flag) { | ||||
| boolean isCreate = false; | boolean isCreate = false; | ||||
| @@ -361,21 +374,30 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| userCreateVideoNumService.addOrSubtractNumberOfTimes(1, videoNum, useCredit, videoTime); | userCreateVideoNumService.addOrSubtractNumberOfTimes(1, videoNum, useCredit, videoTime); | ||||
| } | } | ||||
| @Async | |||||
| public ResultData createVideo(PhotoSpeakVideo photoSpeakVideo) { | |||||
| try { | try { | ||||
| AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | ||||
| param.setTask_id(photoSpeakVideo.getId()); | |||||
| param.setCallback_url(callbackUrl + "/callback/photo/speak"); | |||||
| param.setImg(Base64Util.imageUrlToBase64(photoSpeakVideo.getPersonPhotoUrl())); | param.setImg(Base64Util.imageUrlToBase64(photoSpeakVideo.getPersonPhotoUrl())); | ||||
| param.setVoice_id(voiceMouldSmId == null ? "default" : voiceMouldSmId); | |||||
| String voiceMouldSm = photoSpeakVideo.getVoiceMouldSm(); | String voiceMouldSm = photoSpeakVideo.getVoiceMouldSm(); | ||||
| Integer sex = 1; | |||||
| Integer speakType = 0; | Integer speakType = 0; | ||||
| String mouldSmId = null; | |||||
| if (!StringUtils.isBlank(voiceMouldSm)) { | if (!StringUtils.isBlank(voiceMouldSm)) { | ||||
| JSONObject jsonObject = JSON.parseObject(voiceMouldSm); | JSONObject jsonObject = JSON.parseObject(voiceMouldSm); | ||||
| speakType = jsonObject.getInteger("speakType"); | speakType = jsonObject.getInteger("speakType"); | ||||
| sex = jsonObject.getInteger("sex"); | |||||
| mouldSmId = jsonObject.getString("mouldSmId"); | |||||
| } | } | ||||
| param.setVoice_style(EnumSpeakType.getEnum(speakType).getType()); | |||||
| param.setVoice_style(speakType == null ? "default" : EnumSpeakType.getEnum(speakType).getType()); | |||||
| param.setVoice_id(mouldSmId == null ? "default" : mouldSmId); | |||||
| Integer voiceFrom = photoSpeakVideo.getVoiceFrom(); | |||||
| String voiceMaterialUrl = photoSpeakVideo.getVoiceMaterialUrl(); | |||||
| if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | ||||
| param.setGen_txt(paperwork.replaceAll(str, "[*]")); | |||||
| param.setGen_txt(photoSpeakVideo.getPaperwork().replaceAll(str, "[*]")); | |||||
| if (sex == 1){ | if (sex == 1){ | ||||
| param.setGender("male"); | param.setGender("male"); | ||||
| }else if (sex == 2){ | }else if (sex == 2){ | ||||
| @@ -394,64 +416,82 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| param.setUrl(voiceMaterialUrl); | param.setUrl(voiceMaterialUrl); | ||||
| } | } | ||||
| AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||||
| if (video.isSuccess()) { | |||||
| videoUpd.setVideoPath(video.getUrl()); | |||||
| 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); | |||||
| try { | |||||
| AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||||
| if (video.isSuccess()) { | |||||
| photoSpeakVideo.setSaveDir(video.getSaveDir()); | |||||
| photoSpeakVideo.setAudioPath(video.getAudioPath()); | |||||
| photoSpeakVideo.setVideoPath(video.getUrl()); | |||||
| this.updateById(photoSpeakVideo); | |||||
| return new ResultData(); | |||||
| } | |||||
| photoSpeakVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| photoSpeakVideo.setVideoMsg(video.getMsg()); | |||||
| this.updateById(photoSpeakVideo); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), video.getMsg()); | |||||
| }catch (Exception e){ | |||||
| photoSpeakVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| photoSpeakVideo.setVideoMsg("Meta接口请求异常"); | |||||
| this.updateById(photoSpeakVideo); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"Meta接口请求异常"); | |||||
| } | } | ||||
| return new AsyncResult<>(0); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| if (flag) { | |||||
| //如果生成视频失败了,就把创建视频积分加回去 | |||||
| userCreateVideoNumService.addOrSubtractNumberOfTimes(2, videoNum, useCredit, videoTime); | |||||
| } | |||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| videoUpd.setVideoMsg("请求异常"); | |||||
| this.saveOrUpdate(videoUpd); | |||||
| return new AsyncResult<>(0); | |||||
| photoSpeakVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| photoSpeakVideo.setVideoMsg("接口请求异常"); | |||||
| this.updateById(photoSpeakVideo); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"生成视频失败"); | |||||
| } | } | ||||
| } | } | ||||
| @Async | |||||
| @Override | @Override | ||||
| public void uploadVideo(PhotoSpeakVideo mouldVideo){ | public void uploadVideo(PhotoSpeakVideo mouldVideo){ | ||||
| if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus()) | if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus()) | ||||
| || EnumVideoStatus.upload_fail.getCode().equals(mouldVideo.getVideoStatus())){ | || EnumVideoStatus.upload_fail.getCode().equals(mouldVideo.getVideoStatus())){ | ||||
| String url = mouldVideo.getPhotoSpeakPathUri() + mouldVideo.getVideoPath(); | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | |||||
| String url1 = url + mouldVideo.getVideoPath(); | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url1); | |||||
| if(result.isSuccess()){ | if(result.isSuccess()){ | ||||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | ||||
| videoUpd.setId(mouldVideo.getId()); | videoUpd.setId(mouldVideo.getId()); | ||||
| videoUpd.setVideoId(result.getVideoId()); | videoUpd.setVideoId(result.getVideoId()); | ||||
| videoUpd.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); | videoUpd.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); | ||||
| this.saveOrUpdate(videoUpd); | this.saveOrUpdate(videoUpd); | ||||
| AtomicInteger integer = new AtomicInteger(30); | |||||
| while (true){ | |||||
| try { | |||||
| String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); | |||||
| Thread.sleep(1000); | |||||
| if (StringUtils.isNotEmpty(progress) && progress.equals("complete")) { | |||||
| VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(result.getVideoId()); | |||||
| if (videoDetail.isSuccess() | |||||
| && StringUtils.isNotBlank(videoDetail.getDuration()) | |||||
| && !"0.0".equals(videoDetail.getDuration())) { | |||||
| mouldVideo.setCoverImg(videoDetail.getCoverURL()); | |||||
| mouldVideo.setVideoPlayUrl(videoDetail.getVideoUrl()); | |||||
| mouldVideo.setVideoTime(videoDetail.getDuration()); | |||||
| mouldVideo.setVideoSize(videoDetail.getSize()); | |||||
| mouldVideo.setVideoStatus(EnumVideoStatus.upload_success.getCode()); | |||||
| this.updateById(mouldVideo); | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (integer.getAndDecrement() <= 0){ | |||||
| mouldVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); | |||||
| this.updateById(mouldVideo); | |||||
| break; | |||||
| } | |||||
| } catch (InterruptedException e) { | |||||
| e.printStackTrace(); | |||||
| mouldVideo.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
| mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); | |||||
| this.updateById(mouldVideo); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -490,4 +530,126 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
| return photoSpeakVideoMapper.updateById(video); | return photoSpeakVideoMapper.updateById(video); | ||||
| } | } | ||||
| @Override | |||||
| @Async | |||||
| public ResultData videoHy(PhotoSpeakVideo speakVideo) { | |||||
| try { | |||||
| AiVideoHqParam param = new AiVideoHqParam(); | |||||
| param.setSave_dir(speakVideo.getSaveDir()); | |||||
| param.setAudio_path(speakVideo.getAudioPath()); | |||||
| param.setTask_id(speakVideo.getId()); | |||||
| param.setCallback_url(callbackUrl + "/callback/photo/speak"); | |||||
| try { | |||||
| AiVideoHqResult result = AiVideoHelper.videoHq(param); | |||||
| if (result.isSuccess()) { | |||||
| speakVideo.setVideoHyStatus(EnumVideoStatus.success.getCode()); | |||||
| speakVideo.setVideoMsg("超分视频生成成功"); | |||||
| speakVideo.setVideoPath(result.getUrl()); | |||||
| this.updateById(speakVideo); | |||||
| return new ResultData(); | |||||
| } | |||||
| speakVideo.setVideoHyStatus(EnumVideoStatus.draft.getCode()); | |||||
| speakVideo.setVideoMsg("Mata视频超分失败"); | |||||
| this.updateById(speakVideo); | |||||
| return new ResultData(result.getCode(), result.getMsgInfo(result.getCode(),result.getMsg())); | |||||
| }catch (Exception e){ | |||||
| e.printStackTrace(); | |||||
| speakVideo.setVideoHyStatus(EnumVideoStatus.draft.getCode()); | |||||
| speakVideo.setVideoMsg("Mata视频超分失败"); | |||||
| this.updateById(speakVideo); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"Meta接口请求异常"); | |||||
| } | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| speakVideo.setVideoHyStatus(EnumVideoStatus.draft.getCode()); | |||||
| speakVideo.setVideoMsg("接口请求异常"); | |||||
| this.updateById(speakVideo); | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "接口请求异常"); | |||||
| } | |||||
| } | |||||
| @Async | |||||
| @Override | |||||
| public void uploadHyVideo(PhotoSpeakVideo mouldVideo){ | |||||
| if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoHyStatus()) | |||||
| || EnumVideoStatus.upload_fail.getCode().equals(mouldVideo.getVideoHyStatus())){ | |||||
| String url = hy_url + mouldVideo.getVideoPath(); | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | |||||
| if(result.isSuccess()){ | |||||
| PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | |||||
| videoUpd.setId(mouldVideo.getId()); | |||||
| videoUpd.setVideoId(result.getVideoId()); | |||||
| videoUpd.setVideoHyStatus(EnumVideoStatus.upload_ing.getCode()); | |||||
| this.saveOrUpdate(videoUpd); | |||||
| AtomicInteger integer = new AtomicInteger(30); | |||||
| while (true){ | |||||
| try { | |||||
| String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); | |||||
| Thread.sleep(1000); | |||||
| if (progress.equals("complete")) { | |||||
| VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(result.getVideoId()); | |||||
| if (videoDetail.isSuccess() | |||||
| && StringUtils.isNotBlank(videoDetail.getDuration()) | |||||
| && !"0.0".equals(videoDetail.getDuration())) { | |||||
| mouldVideo.setCoverImg(videoDetail.getCoverURL()); | |||||
| mouldVideo.setVideoPlayUrl(videoDetail.getVideoUrl()); | |||||
| mouldVideo.setVideoTime(videoDetail.getDuration()); | |||||
| mouldVideo.setVideoSize(videoDetail.getSize()); | |||||
| mouldVideo.setIsHy(2);//超分视频生成成功了状态为2 | |||||
| mouldVideo.setVideoHyStatus(EnumVideoStatus.upload_success.getCode()); | |||||
| this.updateById(mouldVideo); | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (integer.getAndDecrement() <= 0){ | |||||
| mouldVideo.setVideoHyStatus(EnumVideoStatus.fail.getCode()); | |||||
| mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); | |||||
| this.updateById(mouldVideo); | |||||
| break; | |||||
| } | |||||
| } catch (InterruptedException e) { | |||||
| e.printStackTrace(); | |||||
| mouldVideo.setVideoHyStatus(EnumVideoStatus.fail.getCode()); | |||||
| mouldVideo.setVideoMsg("视频上传失败,点击“编辑”重试"); | |||||
| this.updateById(mouldVideo); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public List<PhotoSpeakVideo> getUpLoadHyIngList() { | |||||
| PhotoSpeakVideo umVideoQ = new PhotoSpeakVideo(); | |||||
| umVideoQ.setVideoHyStatus(EnumVideoStatus.upload_ing.getCode()); | |||||
| return photoSpeakVideoMapper.getSortList(umVideoQ); | |||||
| } | |||||
| @Override | |||||
| public List<PhotoSpeakVideo> getNotHyUploadList() { | |||||
| PhotoSpeakVideo umVideoQ = new PhotoSpeakVideo(); | |||||
| List<Integer> videoStatuss = new ArrayList<>(); | |||||
| videoStatuss.add(EnumVideoStatus.success.getCode()); | |||||
| videoStatuss.add(EnumVideoStatus.upload_fail.getCode()); | |||||
| umVideoQ.setVideoStatuss(videoStatuss); | |||||
| return photoSpeakVideoMapper.getSortList(umVideoQ); | |||||
| } | |||||
| @Override | |||||
| public ResultData checkVideoStatus(Long userId, List<Long> list, Integer type) { | |||||
| if (CollectionUtils.isEmpty(list)){ | |||||
| return new ResultData(ErrorCode.VIDEO_CREATING.getCode(),""); | |||||
| } | |||||
| if (type == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"类型不能为空"); | |||||
| } | |||||
| Integer integer = photoSpeakVideoMapper.checkVideoStatus(userId,list,type); | |||||
| if (integer > 0){ | |||||
| return new ResultData("生成视频成功"); | |||||
| } | |||||
| return new ResultData(ErrorCode.VIDEO_CREATING.getCode(),"视频生成中"); | |||||
| } | |||||
| } | } | ||||
| @@ -8,6 +8,7 @@ import com.google.common.collect.Lists; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.sm.VoiceInfo; | import com.iformall.domain.po.sm.VoiceInfo; | ||||
| import com.iformall.domain.vo.VoiceInfoVo; | |||||
| import com.iformall.enums.EnumSex; | import com.iformall.enums.EnumSex; | ||||
| import com.iformall.enums.EnumSpeakType; | import com.iformall.enums.EnumSpeakType; | ||||
| import com.iformall.mapper.VoiceMapper; | import com.iformall.mapper.VoiceMapper; | ||||
| @@ -28,20 +29,35 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||||
| private VoiceMapper voiceMapper; | private VoiceMapper voiceMapper; | ||||
| private final static String str = "\uD83D\uDD57"; | private final static String str = "\uD83D\uDD57"; | ||||
| private final static String url = "https://suimang.oss-accelerate.aliyuncs.com/builtin/tts_all_sample/"; | |||||
| private final static String end = ".wav"; | |||||
| @Override | @Override | ||||
| public List<VoiceInfo> chooseType(Long id) { | public List<VoiceInfo> chooseType(Long id) { | ||||
| List<VoiceInfo> voiceInfos = voiceMapper.selectList(new LambdaQueryWrapper<VoiceInfo>().eq(VoiceInfo::getLanguageId, id).orderByAsc(VoiceInfo::getDisplayName).select(VoiceInfo::getId, VoiceInfo::getDisplayName, VoiceInfo::getStyleList,VoiceInfo::getSex)); | |||||
| List<VoiceInfo> voiceInfos = voiceMapper.selectList(new LambdaQueryWrapper<VoiceInfo>().eq(VoiceInfo::getLanguageId, id).orderByAsc(VoiceInfo::getDisplayName)); | |||||
| voiceInfos.forEach(x -> { | voiceInfos.forEach(x -> { | ||||
| if (StringUtils.isNotEmpty(x.getStyleList())) { | if (StringUtils.isNotEmpty(x.getStyleList())) { | ||||
| List<String> strings = JSON.parseArray(x.getStyleList(), String.class); | List<String> strings = JSON.parseArray(x.getStyleList(), String.class); | ||||
| List<String> list = new ArrayList<>(); | |||||
| List<VoiceInfoVo> list = new ArrayList<>(); | |||||
| strings.forEach(y->{ | strings.forEach(y->{ | ||||
| list.add(EnumSpeakType.getEnum(y).getMessage()); | |||||
| VoiceInfoVo infoVo = new VoiceInfoVo(); | |||||
| infoVo.setName(EnumSpeakType.getEnum(y).getMessage()); | |||||
| infoVo.setUrl(url + x.getMouldSmId() + "_" + y + end); | |||||
| list.add(infoVo); | |||||
| }); | }); | ||||
| VoiceInfoVo infoVo = new VoiceInfoVo(); | |||||
| infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | |||||
| infoVo.setUrl(url + x.getMouldSmId() + "_" + "default" + end); | |||||
| list.add(infoVo); | |||||
| x.setStyle(list); | x.setStyle(list); | ||||
| } else { | } else { | ||||
| x.setStyle(Lists.newArrayList()); | |||||
| List<VoiceInfoVo> list = Lists.newArrayList(); | |||||
| VoiceInfoVo infoVo = new VoiceInfoVo(); | |||||
| infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | |||||
| infoVo.setUrl(url + x.getMouldSmId() + "_" + "default" + end); | |||||
| list.add(infoVo); | |||||
| x.setStyle(list); | |||||
| } | } | ||||
| }); | }); | ||||
| return voiceInfos; | return voiceInfos; | ||||
| @@ -65,8 +81,8 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||||
| param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); | param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); | ||||
| AiPreviewResult result = AiVideoHelper.voicePreview(param); | AiPreviewResult result = AiVideoHelper.voicePreview(param); | ||||
| if (result.isSuccess()){ | if (result.isSuccess()){ | ||||
| return new ResultData(result.getUrl()); | |||||
| return new ResultData(result.getTime()); | |||||
| } | } | ||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), result.getMsg()); | |||||
| return new ResultData(result.getCode(), result.getMsgInfo(result.getCode(),result.getMsg())); | |||||
| } | } | ||||
| } | } | ||||
| @@ -20,7 +20,7 @@ public class VoiceLanguageServiceImpl implements VoiceLanguageService { | |||||
| @Override | @Override | ||||
| public List<VoiceLanguage> voiceTotal() { | public List<VoiceLanguage> voiceTotal() { | ||||
| List<VoiceLanguage> languages = voiceLanguageMapper.selectList(new LambdaQueryWrapper<VoiceLanguage>().eq(VoiceLanguage::getIsDel, 0).orderByAsc(VoiceLanguage::getName)); | |||||
| List<VoiceLanguage> languages = voiceLanguageMapper.selectList(new LambdaQueryWrapper<VoiceLanguage>().eq(VoiceLanguage::getIsDel, 0).orderByAsc(VoiceLanguage::getLocal)); | |||||
| return CollectionUtils.isEmpty(languages) ? Lists.newArrayList() : languages; | return CollectionUtils.isEmpty(languages) ? Lists.newArrayList() : languages; | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,11 @@ | |||||
| package com.iformall.sm; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class AiBaiduCheckResult { | |||||
| private boolean success; | |||||
| private String msg; | |||||
| private Integer code; | |||||
| } | |||||
| @@ -6,27 +6,25 @@ import lombok.Data; | |||||
| @Data | @Data | ||||
| public class AiCheckPhotoResult { | public class AiCheckPhotoResult { | ||||
| private boolean success; | |||||
| private String msg; | |||||
| private Integer code; | |||||
| private boolean success; | |||||
| private String msg; | |||||
| private Integer code; | |||||
| public String getMsgInfo(Integer code,String msg){ | |||||
| if (code == 10 && msg.equals("unknown error")) { | |||||
| return "系统服务异常"; | |||||
| }else if (code == 2000 && msg.equals("success")){ | |||||
| return "成功"; | |||||
| }else if (code == 2001 && msg.equals("no face")){ | |||||
| return "图片中没有人脸"; | |||||
| }else if (code == 2002 && msg.equals("more face")){ | |||||
| return "图片中人脸大于1个"; | |||||
| }else if (code == 2003 && msg.equals("big angle")){ | |||||
| return "图片中人脸转动角度太大"; | |||||
| }else if (code == 2004 && msg.equals("big mouth angle")){ | |||||
| return "图片中嘴张开太大"; | |||||
| }else if (code == 2005 && msg.equals("Sensitive people")){ | |||||
| return "图片中人物可能是敏感人物,比如是政要或者明星"; | |||||
| }else { | |||||
| return msg; | |||||
| } | |||||
| } | |||||
| public String getMsgInfo(Integer code, String msg) { | |||||
| if (code == 2000) { | |||||
| return "成功"; | |||||
| } else if (code == 2001 && msg.equals("no face")) { | |||||
| return "(MetaService)图片中没有人脸"; | |||||
| } else if (code == 2002 && msg.equals("more face")) { | |||||
| return "(MetaService)图片中人脸大于1个"; | |||||
| } else if (code == 2003 && msg.equals("big angle")) { | |||||
| return "(MetaService)图片中人脸转动角度太大"; | |||||
| } else if (code == 2004 && msg.equals("big mouth angle")) { | |||||
| return "图片中嘴张开太大(SM)"; | |||||
| } else if (code == 2005 && msg.equals("Sensitive people")) { | |||||
| return "(MetaService)图片中人物可能是敏感人物,比如是政要或者明星"; | |||||
| } else { | |||||
| return "(MetaService)图片不合规,请重新上传"; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -23,6 +23,8 @@ public class AiPhotoSpeakParam { | |||||
| private String gender; | private String gender; | ||||
| private String url; | private String url; | ||||
| private String img; | private String img; | ||||
| private Long task_id; | |||||
| private String callback_url; | |||||
| public String neglectImgString() { | public String neglectImgString() { | ||||
| StringBuffer str = new StringBuffer(); | StringBuffer str = new StringBuffer(); | ||||
| @@ -32,7 +34,9 @@ public class AiPhotoSpeakParam { | |||||
| str.append("\"voice_style\":").append("\"").append(voice_style).append("\","); | str.append("\"voice_style\":").append("\"").append(voice_style).append("\","); | ||||
| str.append("\"gender\":").append("\"").append(gender).append("\","); | str.append("\"gender\":").append("\"").append(gender).append("\","); | ||||
| str.append("\"url\":").append("\"").append(url).append("\","); | str.append("\"url\":").append("\"").append(url).append("\","); | ||||
| str.append("\"img\":").append("\"").append(img).append("\"}"); | |||||
| str.append("\"img\":").append("\"").append(img); | |||||
| str.append("\"task_id\":").append("\"").append(task_id); | |||||
| str.append("\"callback_url\":").append("\"").append(callback_url).append("\"}"); | |||||
| return str.toString(); | return str.toString(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -8,18 +8,21 @@ public class AiPhotoSpeakResult { | |||||
| private boolean success; | private boolean success; | ||||
| private String msg; | private String msg; | ||||
| private String url; | private String url; | ||||
| private Integer code; | |||||
| private String saveDir; | |||||
| private String audioPath; | |||||
| public String getMsgInfo(Integer code, String msg) { | public String getMsgInfo(Integer code, String msg) { | ||||
| if (code == 4000 && msg.equals("success")) { | |||||
| if (code == 4000) { | |||||
| return "成功"; | return "成功"; | ||||
| } else if (code == 3006 && msg.equals("miss parameter")) { | } else if (code == 3006 && msg.equals("miss parameter")) { | ||||
| return "却少参数"; | |||||
| return "(MetaService)却少参数"; | |||||
| } else if (code == 3007 && msg.equals("miss gen_txt")) { | } else if (code == 3007 && msg.equals("miss gen_txt")) { | ||||
| return "没有检测到文本"; | |||||
| return "(MetaService)没有检测到文本"; | |||||
| } else if (code == 3008 && msg.equals("check languages")) { | } else if (code == 3008 && msg.equals("check languages")) { | ||||
| return "文字和语种不对应"; | |||||
| return "(MetaService)文字和语种不对应"; | |||||
| } else { | } else { | ||||
| return msg; | |||||
| return "(MetaService:" + msg + ")服务被Avatar攻击..."; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -6,23 +6,23 @@ import lombok.Data; | |||||
| @Data | @Data | ||||
| public class AiPreviewResult { | public class AiPreviewResult { | ||||
| private boolean success; | |||||
| private Integer code; | |||||
| private String msg; | |||||
| private String url; | |||||
| private Double time; | |||||
| private boolean success; | |||||
| private Integer code; | |||||
| private String msg; | |||||
| private String url; | |||||
| private Double time; | |||||
| public String getMsgInfo(Integer code, String msg) { | |||||
| if (code == 3000 && msg.equals("success")) { | |||||
| return "成功"; | |||||
| } else if (code == 3006 && msg.equals("miss parameter")) { | |||||
| return "缺少参数"; | |||||
| } else if (code == 3007 && msg.equals("miss gen_txt")) { | |||||
| return "没有检测到文本"; | |||||
| } else if (code == 3008 && msg.equals("check languages")) { | |||||
| return "文字和语种不对应"; | |||||
| } else { | |||||
| return msg; | |||||
| } | |||||
| } | |||||
| public String getMsgInfo(Integer code, String msg) { | |||||
| if (code == 3000) { | |||||
| return "成功"; | |||||
| } else if (code == 3006 && msg.equals("miss parameter")) { | |||||
| return "(MetaService)缺少参数"; | |||||
| } else if (code == 3007 && msg.equals("miss gen_txt")) { | |||||
| return "(MetaService)没有检测到文本"; | |||||
| } else if (code == 3008 && msg.equals("check languages")) { | |||||
| return "(MetaService)文字和语种不对应"; | |||||
| } else { | |||||
| return "(MetaService)预览失败,请重试"; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -18,6 +18,8 @@ import com.iformall.utils.HttpUtil; | |||||
| import com.iformall.utils.sign.SignUtils; | import com.iformall.utils.sign.SignUtils; | ||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.stereotype.Component; | |||||
| import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | ||||
| import java.security.MessageDigest; | import java.security.MessageDigest; | ||||
| @@ -25,6 +27,7 @@ import java.security.NoSuchAlgorithmException; | |||||
| import java.util.*; | import java.util.*; | ||||
| @Slf4j | @Slf4j | ||||
| @Component | |||||
| public class AiVideoHelper { | public class AiVideoHelper { | ||||
| // public static String uri = "http://222.128.9.132:22266"; | // public static String uri = "http://222.128.9.132:22266"; | ||||
| @@ -33,10 +36,33 @@ public class AiVideoHelper { | |||||
| public static String uri = "http://111.198.0.15:22266"; | public static String uri = "http://111.198.0.15:22266"; | ||||
| // public static String url = "http://nas.pucao.cn:2002"; | // public static String url = "http://nas.pucao.cn:2002"; | ||||
| public static String url = "http://111.198.0.15:22299"; | |||||
| // public static String hy_url = "http://nas.pucao.cn:2002"; | |||||
| // | |||||
| // public static String url = "http://111.198.0.15:22299"; | |||||
| // public static String hy_url = "http://111.198.0.15:22288"; | |||||
| private static String url; | |||||
| @Value("${photo.url}") | |||||
| public void setUrl(String url){ | |||||
| this.url = url; | |||||
| } | |||||
| private static String hy_url; | |||||
| @Value("${photo.hy_url}") | |||||
| public void setHyUrl(String url){ | |||||
| this.hy_url = url; | |||||
| } | |||||
| private static String talk_url; | |||||
| @Value("${photo.talk}") | |||||
| public void setTalkUrl(String url){ | |||||
| this.talk_url = url; | |||||
| } | |||||
| public static String photo_speak_suffix = "/img_talking"; | public static String photo_speak_suffix = "/img_talking"; | ||||
| public static String image_quality_suffix = "/image_qualit"; | public static String image_quality_suffix = "/image_qualit"; | ||||
| public static String voice_preview = "/tts_wav"; | public static String voice_preview = "/tts_wav"; | ||||
| public static String video_hq = "/video_hq"; | |||||
| 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); | ||||
| @@ -105,10 +131,11 @@ public class AiVideoHelper { | |||||
| public static AiPhotoSpeakResult createPhotoSpeakVideo(AiPhotoSpeakParam videoParam) { | public static AiPhotoSpeakResult createPhotoSpeakVideo(AiPhotoSpeakParam videoParam) { | ||||
| String response = doPost(url + photo_speak_suffix, JSONObject.toJSONString(videoParam)); | String response = doPost(url + photo_speak_suffix, JSONObject.toJSONString(videoParam)); | ||||
| log.info("生成视频end response:" + response); | log.info("生成视频end response:" + response); | ||||
| log.info("生成视频的 IP:" + url + photo_speak_suffix); | |||||
| AiPhotoSpeakResult result = new AiPhotoSpeakResult(); | AiPhotoSpeakResult result = new AiPhotoSpeakResult(); | ||||
| if (StringUtils.isBlank(response)) { | if (StringUtils.isBlank(response)) { | ||||
| result.setSuccess(false); | result.setSuccess(false); | ||||
| result.setMsg("请求生成视频异常,请稍后重试"); | |||||
| result.setMsg("(MetaService empty)服务被Avatar攻击..."); | |||||
| return result; | return result; | ||||
| } | } | ||||
| @@ -118,19 +145,25 @@ public class AiVideoHelper { | |||||
| String msg = status.getString("msg"); | String msg = status.getString("msg"); | ||||
| if (code == null) { | if (code == null) { | ||||
| result.setSuccess(false); | result.setSuccess(false); | ||||
| result.setMsg("请求生成视频异常,请稍后重试"); | |||||
| result.setMsg("(MetaService code empty)服务被Avatar攻击..."); | |||||
| return result; | return result; | ||||
| } | } | ||||
| if (code.intValue() == 4000) { | if (code.intValue() == 4000) { | ||||
| JSONObject data = jsonObject.getJSONObject("data"); | JSONObject data = jsonObject.getJSONObject("data"); | ||||
| String videoUrl = data.getString("url"); | String videoUrl = data.getString("url"); | ||||
| String saveDir = data.getString("save_dir"); | |||||
| String audioPath = data.getString("audio_path"); | |||||
| result.setSuccess(true); | result.setSuccess(true); | ||||
| result.setUrl(videoUrl); | result.setUrl(videoUrl); | ||||
| result.setSaveDir(saveDir); | |||||
| result.setCode(code); | |||||
| result.setAudioPath(audioPath); | |||||
| String resultMsg = result.getMsgInfo(code, msg); | String resultMsg = result.getMsgInfo(code, msg); | ||||
| result.setMsg(resultMsg); | result.setMsg(resultMsg); | ||||
| } else { | } else { | ||||
| result.setSuccess(false); | result.setSuccess(false); | ||||
| result.setCode(code); | |||||
| String resultMsg = result.getMsgInfo(code, msg); | String resultMsg = result.getMsgInfo(code, msg); | ||||
| result.setMsg(resultMsg); | result.setMsg(resultMsg); | ||||
| } | } | ||||
| @@ -140,11 +173,12 @@ public class AiVideoHelper { | |||||
| public static AiCheckPhotoResult checkPhoto(AiCheckPhotoParam param) { | public static AiCheckPhotoResult checkPhoto(AiCheckPhotoParam param) { | ||||
| String response = doPost(url + image_quality_suffix, JSONObject.toJSONString(param)); | String response = doPost(url + image_quality_suffix, JSONObject.toJSONString(param)); | ||||
| log.info("图片质量审核 end response:" + response); | log.info("图片质量审核 end response:" + response); | ||||
| log.info("图片质量审核 IP:" + url + image_quality_suffix); | |||||
| AiCheckPhotoResult result = new AiCheckPhotoResult(); | AiCheckPhotoResult result = new AiCheckPhotoResult(); | ||||
| if (StringUtils.isBlank(response)) { | if (StringUtils.isBlank(response)) { | ||||
| result.setSuccess(false); | result.setSuccess(false); | ||||
| result.setMsg("图片质量审核失败,请稍后重试"); | |||||
| result.setMsg("(MetaService)图片质量审核失败,请稍后重试"); | |||||
| return result; | return result; | ||||
| } | } | ||||
| JSONObject jsonObject = JSON.parseObject(response); | JSONObject jsonObject = JSON.parseObject(response); | ||||
| @@ -153,7 +187,7 @@ public class AiVideoHelper { | |||||
| String msg = status.getString("msg"); | String msg = status.getString("msg"); | ||||
| if (code == null) { | if (code == null) { | ||||
| result.setSuccess(false); | result.setSuccess(false); | ||||
| result.setMsg("请求异常,请稍后重试"); | |||||
| result.setMsg("(MetaService)请求图片质量检查失败,请稍后重试"); | |||||
| return result; | return result; | ||||
| } | } | ||||
| if (code.intValue() == 2000) { | if (code.intValue() == 2000) { | ||||
| @@ -173,11 +207,12 @@ public class AiVideoHelper { | |||||
| public static AiPreviewResult voicePreview(AiPreviewParam param) { | public static AiPreviewResult voicePreview(AiPreviewParam param) { | ||||
| String response = doPost(url + voice_preview, JSONObject.toJSONString(param)); | String response = doPost(url + voice_preview, JSONObject.toJSONString(param)); | ||||
| log.info("TTS音色预览 end response:" + response); | log.info("TTS音色预览 end response:" + response); | ||||
| log.info("TTS音色预览 IP:" + url + voice_preview); | |||||
| AiPreviewResult result = new AiPreviewResult(); | AiPreviewResult result = new AiPreviewResult(); | ||||
| if (StringUtils.isBlank(response)) { | if (StringUtils.isBlank(response)) { | ||||
| result.setSuccess(false); | result.setSuccess(false); | ||||
| result.setMsg("TTS音色预览失败,请稍后重试"); | |||||
| result.setMsg("(MetaService)TTS音色预览失败,请稍后重试"); | |||||
| return result; | return result; | ||||
| } | } | ||||
| JSONObject jsonObject = JSON.parseObject(response); | JSONObject jsonObject = JSON.parseObject(response); | ||||
| @@ -194,7 +229,7 @@ public class AiVideoHelper { | |||||
| String msg = status.getString("msg"); | String msg = status.getString("msg"); | ||||
| if (code == null) { | if (code == null) { | ||||
| result.setSuccess(false); | result.setSuccess(false); | ||||
| result.setMsg("TTS音色预览异常,请稍后重试"); | |||||
| result.setMsg("(MetaService)TTS音色预览异常,请稍后重试"); | |||||
| return result; | return result; | ||||
| } | } | ||||
| if (code.intValue() == 3000) { | if (code.intValue() == 3000) { | ||||
| @@ -213,6 +248,47 @@ public class AiVideoHelper { | |||||
| return result; | return result; | ||||
| } | } | ||||
| public static AiVideoHqResult videoHq(AiVideoHqParam param) { | |||||
| String response = doPost(hy_url + video_hq, JSONObject.toJSONString(param)); | |||||
| log.info("视频超分 end response:" + response); | |||||
| log.info("视频超分 IP:" + hy_url + video_hq); | |||||
| AiVideoHqResult result = new AiVideoHqResult(); | |||||
| if (StringUtils.isBlank(response)) { | |||||
| result.setSuccess(false); | |||||
| result.setMsg("(MetaService)视频超分失败,请稍后重试"); | |||||
| return result; | |||||
| } | |||||
| JSONObject jsonObject = JSON.parseObject(response); | |||||
| JSONObject status = jsonObject.getJSONObject("status"); | |||||
| JSONObject data = jsonObject.getJSONObject("data"); | |||||
| String strURL = null; | |||||
| if (data != null){ | |||||
| strURL = data.getString("url"); | |||||
| } | |||||
| Integer code = status.getInteger("code"); | |||||
| String msg = status.getString("msg"); | |||||
| if (code == null) { | |||||
| result.setSuccess(false); | |||||
| result.setMsg("(MetaService)视频超分异常,请稍后重试"); | |||||
| return result; | |||||
| } | |||||
| if (code.intValue() == 3000) { | |||||
| result.setCode(200); | |||||
| result.setSuccess(true); | |||||
| result.setUrl(url + strURL); | |||||
| String resultMsg = result.getMsgInfo(code, msg); | |||||
| result.setMsg(resultMsg); | |||||
| } else { | |||||
| result.setCode(code); | |||||
| result.setSuccess(false); | |||||
| String resultMsg = result.getMsgInfo(code, msg); | |||||
| result.setMsg(resultMsg); | |||||
| } | |||||
| 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("我写了一篇小说,你帮我看看。"); | ||||
| @@ -237,26 +313,43 @@ public class AiVideoHelper { | |||||
| // AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | // AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | ||||
| // param.setGen_txt("人多泰达股份冲冠怒发代发"); | // param.setGen_txt("人多泰达股份冲冠怒发代发"); | ||||
| // param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/digitalperson/16760216806604820_cSHoijDX_matting.png")); | |||||
| // param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/personphoto/16564099737021232.png")); | |||||
| // param.setGender("male"); | // param.setGender("male"); | ||||
| // param.setVoice_id("zh-CN-YunxiNeural"); | |||||
| // param.setVoice_style("sad"); | |||||
| // param.setVoice_id("yue-CN-YunSongNeural"); | |||||
| // param.setVoice_style("default"); | |||||
| // param.setUrl("None"); | // param.setUrl("None"); | ||||
| // AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | // AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | ||||
| AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | |||||
| param.setCallback_url("https://phototest.metavatar.cc/C/callback/photo/speak"); | |||||
| param.setTask_id(836805079248850944L); | |||||
| param.setGen_txt("None"); | |||||
| param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/capi/2023-06-07/6da595fe12ef405bb6434f31e6bad4ec.png")); | |||||
| param.setGender("None"); | |||||
| param.setVoice_id("default"); | |||||
| param.setVoice_style("default"); | |||||
| param.setUrl("https://video.metavatar.cc/sv/262b03bd-18929af12fd/262b03bd-18929af12fd.mp3"); | |||||
| AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||||
| // AiCheckPhotoParam param = new AiCheckPhotoParam(); | // AiCheckPhotoParam param = new AiCheckPhotoParam(); | ||||
| // String img = Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/personmould/16760216806604820_cSHoijDX_grace_1080.jpg"); | // String img = Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/personmould/16760216806604820_cSHoijDX_grace_1080.jpg"); | ||||
| // param.setImg(img); | // param.setImg(img); | ||||
| // AiCheckPhotoResult result = AiVideoHelper.checkPhoto(param); | // AiCheckPhotoResult result = AiVideoHelper.checkPhoto(param); | ||||
| // System.out.println(result); | // System.out.println(result); | ||||
| // | // | ||||
| AiPreviewParam param = new AiPreviewParam(); | |||||
| param.setGen_txt("今天是个好日子"); | |||||
| param.setVoice_id("ar-DZ-AminaNeural"); | |||||
| param.setVoice_style("default"); | |||||
| param.setGender("female"); | |||||
| AiPreviewResult result = AiVideoHelper.voicePreview(param); | |||||
| System.out.println(result); | |||||
| // AiPreviewParam param = new AiPreviewParam(); | |||||
| // param.setGen_txt("今天是个好日子"); | |||||
| // param.setVoice_id("ar-DZ-AminaNeural"); | |||||
| // param.setVoice_style("default"); | |||||
| // param.setGender("female"); | |||||
| // AiPreviewResult result = AiVideoHelper.voicePreview(param); | |||||
| // System.out.println(result); | |||||
| // AiVideoHqParam param = new AiVideoHqParam(); | |||||
| // param.setSave_dir("static/video/2023-07-06/16886220017209544_wav.mp4"); | |||||
| // param.setAudio_path("static/mp3/2023-07-06/291ab7dc-18929b6e89e_convert.wav"); | |||||
| // AiVideoHqResult result = AiVideoHelper.videoHq(param); | |||||
| // System.out.println(result); | |||||
| } | } | ||||
| @@ -0,0 +1,12 @@ | |||||
| package com.iformall.sm; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class AiVideoHqParam { | |||||
| private String save_dir; | |||||
| private String audio_path; | |||||
| private Long task_id; | |||||
| private String callback_url; | |||||
| } | |||||
| @@ -0,0 +1,19 @@ | |||||
| package com.iformall.sm; | |||||
| import lombok.Data; | |||||
| @Data | |||||
| public class AiVideoHqResult { | |||||
| private boolean success; | |||||
| private Integer code; | |||||
| private String msg; | |||||
| private String url; | |||||
| public String getMsgInfo(Integer code, String msg) { | |||||
| if (code == 5000) { | |||||
| return "成功"; | |||||
| } else { | |||||
| return "(MetaService)视频超分失败,点击“编辑”重试"; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -27,6 +27,11 @@ | |||||
| <result column="video_status" jdbcType="INTEGER" property="videoStatus"/> | <result column="video_status" jdbcType="INTEGER" property="videoStatus"/> | ||||
| <result column="video_msg" jdbcType="VARCHAR" property="videoMsg"/> | <result column="video_msg" jdbcType="VARCHAR" property="videoMsg"/> | ||||
| <result column="is_hy" jdbcType="INTEGER" property="isHy"/> | |||||
| <result column="video_hy_status" jdbcType="INTEGER" property="videoHyStatus"/> | |||||
| <result column="music_id" jdbcType="VARCHAR" property="musicId"/> | |||||
| <result column="save_dir" jdbcType="VARCHAR" property="saveDir"/> | |||||
| <result column="create_video_date" jdbcType="TIMESTAMP" property="createVideoDate"/> | <result column="create_video_date" jdbcType="TIMESTAMP" property="createVideoDate"/> | ||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | ||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | ||||
| @@ -35,7 +40,8 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`, `tenant_id`, `parent_tenant_id`, `user_id`, | `id`, `tenant_id`, `parent_tenant_id`, `user_id`, | ||||
| `person_photo_id`, `person_photo_url`, `voice_from`, `voice_mould_id`, `voice_mould_sm`, `paperwork`, `voice_material_id`, `voice_material_url`, | `person_photo_id`, `person_photo_url`, `voice_from`, `voice_mould_id`, `voice_mould_sm`, `paperwork`, `voice_material_id`, `voice_material_url`, | ||||
| `title`, `cover_img`, `remark`, `video_id`, `video_path`, `video_play_url`, `video_time`, `video_size`, `video_status`, `video_msg`, `create_video_date`, `create_date`, `update_date` | |||||
| `title`, `cover_img`, `remark`, `video_id`, `video_path`, `video_play_url`, `video_time`, `video_size`, `video_status`, `video_msg`, `create_video_date`, `create_date`, `update_date`, | |||||
| `is_hy`,`video_hy_status`,`music_id`,`save_dir` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -59,6 +65,15 @@ | |||||
| <if test=" null != voiceFrom "> | <if test=" null != voiceFrom "> | ||||
| and `voice_from` = #{voiceFrom} | and `voice_from` = #{voiceFrom} | ||||
| </if> | </if> | ||||
| <if test=" null != isHy "> | |||||
| and `is_hy` = #{isHy} | |||||
| </if> | |||||
| <if test=" null != musicId "> | |||||
| and `music_id` = #{musicId} | |||||
| </if> | |||||
| <if test=" null != saveDir "> | |||||
| and `save_dir` = #{saveDir} | |||||
| </if> | |||||
| <if test=" null != voiceMouldId "> | <if test=" null != voiceMouldId "> | ||||
| and `voice_mould_id` = #{voiceMouldId} | and `voice_mould_id` = #{voiceMouldId} | ||||
| @@ -71,6 +86,9 @@ | |||||
| <if test=" null != videoStatus "> | <if test=" null != videoStatus "> | ||||
| and `video_status` = #{videoStatus} | and `video_status` = #{videoStatus} | ||||
| </if> | </if> | ||||
| <if test=" null != videoHyStatus "> | |||||
| and `video_hy_status` = #{videoHyStatus} | |||||
| </if> | |||||
| <if test=" null != startDate "> | <if test=" null != startDate "> | ||||
| and create_date >= #{startDate} | and create_date >= #{startDate} | ||||
| @@ -119,7 +137,7 @@ | |||||
| `id`, | `id`, | ||||
| `paperwork`, | `paperwork`, | ||||
| `title`, `cover_img`, `remark`, `video_id`, `video_path`, `video_play_url`, `video_time`, `video_size`, `video_status`,`video_msg`, | `title`, `cover_img`, `remark`, `video_id`, `video_path`, `video_play_url`, `video_time`, `video_size`, `video_status`,`video_msg`, | ||||
| `create_video_date`, `create_date`, `update_date` | |||||
| `create_video_date`, `create_date`, `update_date`,`is_hy`,`video_hy_status` | |||||
| from photo_speak_video | from photo_speak_video | ||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||
| @@ -138,5 +156,22 @@ | |||||
| <include refid="dynamicWhereConditions"/> | <include refid="dynamicWhereConditions"/> | ||||
| </select> | </select> | ||||
| <select id="checkVideoStatus" resultType="java.lang.Integer"> | |||||
| select count(1) | |||||
| from photo_speak_video | |||||
| where user_id = #{userId} | |||||
| <if test="type == 1"> | |||||
| and video_status = 5 | |||||
| </if> | |||||
| <if test="type == 2"> | |||||
| and video_hy_status = 5 | |||||
| </if> | |||||
| <if test="list != null and list.size > 0"> | |||||
| and id in | |||||
| <foreach collection="list" index="index" item="id" open="(" separator="," close=")"> | |||||
| #{id} | |||||
| </foreach> | |||||
| </if> | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||
| @@ -3,7 +3,7 @@ | |||||
| <mapper namespace="com.iformall.mapper.VoiceLanguageMapper"> | <mapper namespace="com.iformall.mapper.VoiceLanguageMapper"> | ||||
| <insert id="saveBatch" parameterType="java.util.HashSet"> | <insert id="saveBatch" parameterType="java.util.HashSet"> | ||||
| INSERT INTO voice_language (`id`, `country`, | INSERT INTO voice_language (`id`, `country`, | ||||
| `language`, `local`, `name`, `img`, `is_del`) | |||||
| `language`, `local`, `name`, `img`, `is_del`,`chinese_name`) | |||||
| VALUES | VALUES | ||||
| <foreach collection="set" item="item" separator=","> | <foreach collection="set" item="item" separator=","> | ||||
| ( | ( | ||||
| @@ -13,7 +13,8 @@ | |||||
| #{item.local}, | #{item.local}, | ||||
| #{item.name}, | #{item.name}, | ||||
| #{item.img}, | #{item.img}, | ||||
| #{item.isDel} | |||||
| #{item.isDel}, | |||||
| #{item.chineseName} | |||||
| ) | ) | ||||
| </foreach> | </foreach> | ||||
| </insert> | </insert> | ||||
| @@ -5,7 +5,7 @@ | |||||
| INSERT INTO voice_info (`id`, `language_id`, `sex`, | INSERT INTO voice_info (`id`, `language_id`, `sex`, | ||||
| `display_name`, `local_name`, `mould_sm_id`, | `display_name`, `local_name`, `mould_sm_id`, | ||||
| `sample_rate_hertz`, `words_per_minute`, `voice_type`, | `sample_rate_hertz`, `words_per_minute`, `voice_type`, | ||||
| `style_list`, `create_date`, `update_date`, `is_del`) | |||||
| `style_list`, `create_date`, `update_date`, `is_del`,`age_type`) | |||||
| VALUES | VALUES | ||||
| <foreach collection="list" item="item" separator=","> | <foreach collection="list" item="item" separator=","> | ||||
| ( | ( | ||||
| @@ -21,7 +21,8 @@ | |||||
| #{item.styleList}, | #{item.styleList}, | ||||
| #{item.createDate}, | #{item.createDate}, | ||||
| #{item.updateDate}, | #{item.updateDate}, | ||||
| #{item.isDel} | |||||
| #{item.isDel}, | |||||
| #{item.ageType} | |||||
| ) | ) | ||||
| </foreach> | </foreach> | ||||
| </insert> | </insert> | ||||
| @@ -1,11 +1,9 @@ | |||||
| package com.iformall.video; | package com.iformall.video; | ||||
| import java.io.File; | |||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import com.iformall.video.entity.VideTransResult; | import com.iformall.video.entity.VideTransResult; | ||||
| import com.iformall.video.entity.VideUploadResult; | import com.iformall.video.entity.VideUploadResult; | ||||
| import org.apache.commons.lang3.StringUtils; | |||||
| public interface VideoExcutor { | public interface VideoExcutor { | ||||