|
|
@@ -35,6 +35,7 @@ public class AiVideoHelper { |
|
|
|
public static String photo_speak_suffix = "/img_talking"; |
|
|
|
public static String image_quality_suffix = "/image_qualit"; |
|
|
|
public static String voice_preview = "/tts_wav"; |
|
|
|
public static String video_hq = "/video_hq"; |
|
|
|
|
|
|
|
public static String doPost(String url, String params) { |
|
|
|
return HttpUtil.doAiVideoPost(url,params); |
|
|
@@ -123,8 +124,10 @@ public class AiVideoHelper { |
|
|
|
if (code.intValue() == 4000) { |
|
|
|
JSONObject data = jsonObject.getJSONObject("data"); |
|
|
|
String videoUrl = data.getString("url"); |
|
|
|
String saveDir = data.getString("save_dir"); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setUrl(videoUrl); |
|
|
|
result.setSaveDir(saveDir); |
|
|
|
String resultMsg = result.getMsgInfo(code, msg); |
|
|
|
result.setMsg(resultMsg); |
|
|
|
} else { |
|
|
@@ -211,6 +214,46 @@ public class AiVideoHelper { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
public static AiVideoHqResult videoHq(AiVideoHqParam param) { |
|
|
|
String response = doPost(url + video_hq, JSONObject.toJSONString(param)); |
|
|
|
log.info("视频超分 end response:" + response); |
|
|
|
AiVideoHqResult result = new AiVideoHqResult(); |
|
|
|
|
|
|
|
if (StringUtils.isBlank(response)) { |
|
|
|
result.setSuccess(false); |
|
|
|
result.setMsg("视频超分失败,请稍后重试"); |
|
|
|
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("视频超分异常,请稍后重试"); |
|
|
|
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) { |
|
|
|
// AiVideoParam videoParam = new AiVideoParam(); |
|
|
|
// videoParam.setGen_txt("我写了一篇小说,你帮我看看。"); |
|
|
@@ -233,14 +276,14 @@ public class AiVideoHelper { |
|
|
|
// AiVideoResult video = AiVideoHelper.createVideo(videoParam); |
|
|
|
// |
|
|
|
|
|
|
|
// AiPhotoSpeakParam param = new AiPhotoSpeakParam(); |
|
|
|
// param.setGen_txt("人多泰达股份冲冠怒发代发"); |
|
|
|
// param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/digitalperson/16760216806604820_cSHoijDX_matting.png")); |
|
|
|
// param.setGender("male"); |
|
|
|
// param.setVoice_id("zh-CN-YunxiNeural"); |
|
|
|
// param.setVoice_style("sad"); |
|
|
|
// param.setUrl("None"); |
|
|
|
// AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); |
|
|
|
AiPhotoSpeakParam param = new AiPhotoSpeakParam(); |
|
|
|
param.setGen_txt("人多泰达股份冲冠怒发代发"); |
|
|
|
param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/digitalperson/16760216806604820_cSHoijDX_matting.png")); |
|
|
|
param.setGender("male"); |
|
|
|
param.setVoice_id("zh-CN-YunyangNeural"); |
|
|
|
param.setVoice_style("default"); |
|
|
|
param.setUrl("None"); |
|
|
|
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); |
|
|
|
|
|
|
|
// AiCheckPhotoParam param = new AiCheckPhotoParam(); |
|
|
|
// String img = Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/personmould/16760216806604820_cSHoijDX_grace_1080.jpg"); |
|
|
@@ -248,13 +291,18 @@ public class AiVideoHelper { |
|
|
|
// AiCheckPhotoResult result = AiVideoHelper.checkPhoto(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); |
|
|
|
// 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(); |
|
|
|
// AiPreviewResult result = AiVideoHelper.voicePreview(param); |
|
|
|
// System.out.println(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|