|
|
@@ -116,8 +116,9 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
voiceMouldObject.put("personTypeStr","default"); |
|
|
|
voiceMouldObject.put("speakType",0); |
|
|
|
voiceMouldObject.put("speakTypeStr","default"); |
|
|
|
EnumSpeakType speakType = null; |
|
|
|
if(StringUtils.isNotBlank(record.getSpeakTypeStr())){ |
|
|
|
EnumSpeakType speakType = EnumSpeakType.getEnumByMsg(record.getSpeakTypeStr()); |
|
|
|
speakType = EnumSpeakType.getEnumByMsg(record.getSpeakTypeStr()); |
|
|
|
if(speakType == null){ |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"声音类型信息错误"); |
|
|
|
} |
|
|
@@ -206,7 +207,14 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
Integer voiceFrom = photoSpeakVideo.getVoiceFrom(); |
|
|
|
String voiceMouldSmId = null; |
|
|
|
String voiceType = "default";//默认 |
|
|
|
|
|
|
|
Integer sex = 1; |
|
|
|
Long residueTime = 0L; |
|
|
|
UserCreateVideoNum videoNum = userCreateVideoNumService.queryInfoByUserId(photoSpeakVideo.getUserId()); |
|
|
|
if (videoNum == null) { |
|
|
|
msg = "没有创建视频时长"; |
|
|
|
}else { |
|
|
|
residueTime = videoNum.getResidueTime(); |
|
|
|
} |
|
|
|
String voiceMaterialUrl = null; |
|
|
|
if(EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)){ |
|
|
|
try{ |
|
|
@@ -214,6 +222,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
voiceMouldSmId = personMouldObject.getString("mouldSmId"); |
|
|
|
Integer speakType = personMouldObject.getInteger("speakType"); |
|
|
|
Integer personType = personMouldObject.getInteger("personType"); |
|
|
|
sex = personMouldObject.getInteger("sex"); |
|
|
|
if(speakType != null && speakType > 0){ |
|
|
|
voiceType = EnumSpeakType.getEnum(speakType).getMessage(); |
|
|
|
}else if(personType != null && personType > 0){ |
|
|
@@ -224,6 +233,21 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
if(StringUtils.isBlank(voiceMouldSmId)){ |
|
|
|
msg = "参数错误,未找到声音模板数据"; |
|
|
|
} |
|
|
|
//判断用户时长是否够创建该视频 |
|
|
|
AiPreviewParam param = new AiPreviewParam(); |
|
|
|
if (StringUtils.isBlank(photoSpeakVideo.getPaperwork())){ |
|
|
|
msg = "未填写视频文案数据"; |
|
|
|
} |
|
|
|
param.setGen_txt(photoSpeakVideo.getPaperwork().replaceAll(str, "[*]")); |
|
|
|
param.setGender(sex == 1 ? "male" : "female"); |
|
|
|
param.setVoice_id(voiceMouldSmId); |
|
|
|
param.setVoice_style(voiceType); |
|
|
|
AiPreviewResult result = AiVideoHelper.voicePreview(param); |
|
|
|
if (result.isSuccess()) { |
|
|
|
if (residueTime < result.getTime()) { |
|
|
|
msg = "创建视频时长不足,请充值"; |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)){ |
|
|
|
voiceMaterialUrl = photoSpeakVideo.getVoiceMaterialUrl(); |
|
|
|
if(StringUtils.isBlank(voiceMaterialUrl)){ |
|
|
@@ -235,6 +259,14 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
if(StringUtils.isBlank(voiceMaterialUrl)){ |
|
|
|
msg = "未找到上传声音文件"; |
|
|
|
} |
|
|
|
//判断用户时长是否够创建该视频 |
|
|
|
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(photoSpeakVideo.getVideoId()); |
|
|
|
if (videoDetail.isSuccess() && StringUtils.isNotBlank(videoDetail.getDuration()) && !"0.0".equals(videoDetail.getDuration())) { |
|
|
|
String duration = videoDetail.getDuration(); |
|
|
|
if (residueTime < Long.parseLong(duration)) { |
|
|
|
msg = "创建视频时长余额不足,请充值"; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (EnumVoiceFrom.MUSIC.getCode().equals(voiceFrom)) { |
|
|
|
Long musicId = photoSpeakVideo.getMusicId(); |
|
|
|
MusicInfo musicInfo = musicInfoService.getById(musicId); |
|
|
@@ -245,6 +277,9 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
if (StringUtils.isBlank(voiceMaterialUrl)) { |
|
|
|
msg = "音乐文件错误"; |
|
|
|
} |
|
|
|
if (residueTime < musicInfo.getTime()) { |
|
|
|
msg ="创建视频时长余额不足,请充值"; |
|
|
|
} |
|
|
|
} else { |
|
|
|
msg = "声音数据异常"; |
|
|
|
} |
|
|
@@ -269,7 +304,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
//修改用户生成视频次数 |
|
|
|
createVideoNum = userCreateVideoNumService.queryInfoByUserId(photoSpeakVideo.getUserId()); |
|
|
|
if (ObjectUtils.isEmpty(createVideoNum)) { |
|
|
|
return new AsyncResult<>("用户没有生成视频次数"); |
|
|
|
return new AsyncResult<>("生成视频"); |
|
|
|
} else { |
|
|
|
//剩余条数 |
|
|
|
Integer residueNum = createVideoNum.getResidueNum(); |
|
|
@@ -295,7 +330,6 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
Integer speakTypeStr = jsonObject.getInteger("speakType"); |
|
|
|
param.setVoice_style(StringUtils.isBlank(voiceType) ? "default" : EnumSpeakType.getEnum(speakTypeStr).getType()); |
|
|
|
|
|
|
|
Integer sex = jsonObject.getInteger("sex"); |
|
|
|
if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { |
|
|
|
param.setGen_txt(paperwork.replaceAll(str, "[*]")); |
|
|
|
if (sex == 1){ |
|
|
@@ -310,6 +344,10 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { |
|
|
|
param.setGen_txt("None"); |
|
|
|
param.setGender("None"); |
|
|
|
param.setUrl(voiceMaterialUrl); |
|
|
|
}else if (EnumVoiceFrom.MUSIC.getCode().equals(voiceFrom)){ |
|
|
|
param.setGen_txt("None"); |
|
|
|
param.setGender("None"); |
|
|
|
param.setUrl(voiceMaterialUrl); |
|
|
|
} |
|
|
|
|
|
|
|
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); |
|
|
|