|
|
|
@ -50,45 +50,51 @@ public class HumanManageServiceImpl implements HumanManageService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void generateSilent(Human human, File imageFile) throws Exception {
|
|
|
|
|
HumanGenerateDTO silentDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + silent, Map.of("image", imageFile));
|
|
|
|
|
silentDTO = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人静态视频异常");
|
|
|
|
|
}
|
|
|
|
|
// 保存静态视频
|
|
|
|
|
if (silentDTO.getCode() == 200) {
|
|
|
|
|
if (StrUtil.isNotBlank(silentDTO.getVideo())) {
|
|
|
|
|
// 如果已经生成了视频,那么直接拿到这个视频
|
|
|
|
|
FileResource fileResource = convertBase64ToFile("silent", FileUtil.getName(imageFile), silentDTO.getVideo());
|
|
|
|
|
human.setSilentVideoFileId(fileResource.getId());
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isAllBlank(human.getSilentVideoFileId(), human.getSilentTaskUid())) {
|
|
|
|
|
HumanGenerateDTO silentDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + silent, Map.of("image", imageFile));
|
|
|
|
|
silentDTO = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人静态视频异常");
|
|
|
|
|
}
|
|
|
|
|
// 保存静态视频
|
|
|
|
|
if (silentDTO.getCode() == 200) {
|
|
|
|
|
if (StrUtil.isNotBlank(silentDTO.getVideo())) {
|
|
|
|
|
// 如果已经生成了视频,那么直接拿到这个视频
|
|
|
|
|
FileResource fileResource = convertBase64ToFile("silent", FileUtil.getName(imageFile), silentDTO.getVideo());
|
|
|
|
|
human.setSilentVideoFileId(fileResource.getId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
human.setSilentTaskUid(silentDTO.getUid());
|
|
|
|
|
}
|
|
|
|
|
human.setSilentTaskUid(silentDTO.getUid());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void generateDynamic(Human human, File imageFile) throws Exception {
|
|
|
|
|
HumanGenerateDTO dynamicDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + dynamic, Map.of("image", imageFile));
|
|
|
|
|
dynamicDTO = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人动态视频异常");
|
|
|
|
|
}
|
|
|
|
|
if (StrUtil.isAllNotBlank(human.getDynamicVideoFileId(), human.getDynamicTaskUid())) {
|
|
|
|
|
HumanGenerateDTO dynamicDTO;
|
|
|
|
|
try {
|
|
|
|
|
String post = HttpUtil.post(humanBaseUrl + dynamic, Map.of("image", imageFile));
|
|
|
|
|
dynamicDTO = JSONUtil.toBean(post, HumanGenerateDTO.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new BusinessException("生成数字人动态视频异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dynamicDTO.getCode() == 200) {
|
|
|
|
|
if (StrUtil.isNotBlank(dynamicDTO.getVideo())) {
|
|
|
|
|
// 如果已经生成了视频,那么直接拿到这个视频
|
|
|
|
|
FileResource fileResource = convertBase64ToFile("dynamic", FileUtil.getName(imageFile), dynamicDTO.getVideo());
|
|
|
|
|
human.setDynamicVideoFileId(fileResource.getId());
|
|
|
|
|
if (dynamicDTO.getCode() == 200) {
|
|
|
|
|
if (StrUtil.isNotBlank(dynamicDTO.getVideo())) {
|
|
|
|
|
// 如果已经生成了视频,那么直接拿到这个视频
|
|
|
|
|
FileResource fileResource = convertBase64ToFile("dynamic", FileUtil.getName(imageFile), dynamicDTO.getVideo());
|
|
|
|
|
human.setDynamicVideoFileId(fileResource.getId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
human.setDynamicTaskUid(dynamicDTO.getUid());
|
|
|
|
|
}
|
|
|
|
|
human.setDynamicTaskUid(dynamicDTO.getUid());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private FileResource convertBase64ToFile(String prefixName, String imageFileName, String base64) throws Exception {
|
|
|
|
|