| @@ -1,54 +0,0 @@ | |||||
| package com.iformall.service.sm.impl; | |||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.enums.EnumSpeakType; | |||||
| import com.iformall.enums.EnumVideoStatus; | |||||
| import com.iformall.enums.EnumVoiceFrom; | |||||
| import com.iformall.service.sm.SDKService; | |||||
| import com.iformall.sm.AiPhotoSpeakParam; | |||||
| import com.iformall.sm.AiPhotoSpeakResult; | |||||
| import com.iformall.sm.AiVideoHelper; | |||||
| import com.iformall.utils.Base64Util; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.scheduling.annotation.AsyncResult; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.Date; | |||||
| @Service | |||||
| public class SDKServiceImpl implements SDKService { | |||||
| @Override | |||||
| public ResultData imgTalking(AiPhotoSpeakParam videoParam) { | |||||
| AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | |||||
| param.setImg(Base64Util.imageUrlToBase64(videoParam.getUrl())); | |||||
| param.setVoice_id(videoParam.getVoice_id()); | |||||
| param.setVoice_style(StringUtils.isBlank(voiceType) ? "default" : EnumSpeakType.getEnum(speakTypeStr).getType()); | |||||
| if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | |||||
| param.setGen_txt(paperwork.replaceAll(str, "[*]")); | |||||
| param.setGender("male"); | |||||
| param.setUrl("None"); | |||||
| } else if (EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)) { | |||||
| param.setGen_txt("None"); | |||||
| param.setGender("None"); | |||||
| 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()); | |||||
| this.uploadVideo(videoUpd); | |||||
| return new AsyncResult<>(1); | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | |||||