Browse Source

新增save_dir 字段、新增超分方法

private_deployment
lrh 1 year ago
parent
commit
7037ff217c
7 changed files with 97 additions and 15 deletions
  1. +2
    -0
      suimangAdmin/src/main/resources/db/migration/V202306281655_photo_speak_video.sql
  2. +2
    -0
      suimangService/src/main/java/com/iformall/domain/po/sm/PhotoSpeakVideo.java
  3. +1
    -0
      suimangService/src/main/java/com/iformall/service/sm/impl/PhotoSpeakVideoServiceImpl.java
  4. +1
    -0
      suimangService/src/main/java/com/iformall/sm/AiPhotoSpeakResult.java
  5. +63
    -15
      suimangService/src/main/java/com/iformall/sm/AiVideoHelper.java
  6. +9
    -0
      suimangService/src/main/java/com/iformall/sm/AiVideoHqParam.java
  7. +19
    -0
      suimangService/src/main/java/com/iformall/sm/AiVideoHqResult.java

+ 2
- 0
suimangAdmin/src/main/resources/db/migration/V202306281655_photo_speak_video.sql View File

@@ -0,0 +1,2 @@
ALTER TABLE `mallink_suimang_test`.`photo_speak_video`
ADD COLUMN `save_dir` varchar(255) NULL COMMENT '超分的视频路径' AFTER `music_id`;

+ 2
- 0
suimangService/src/main/java/com/iformall/domain/po/sm/PhotoSpeakVideo.java View File

@@ -152,5 +152,7 @@ public class PhotoSpeakVideo extends TenantEntity {
private List<Integer> videoStatuss;

private Long musicId;

private String saveDir;
}

+ 1
- 0
suimangService/src/main/java/com/iformall/service/sm/impl/PhotoSpeakVideoServiceImpl.java View File

@@ -397,6 +397,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService {
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param);
if (video.isSuccess()) {
videoUpd.setVideoPath(video.getUrl());
videoUpd.setSaveDir(video.getSaveDir());
videoUpd.setVideoStatus(EnumVideoStatus.success.getCode());
videoUpd.setVideoMsg("success");
videoUpd.setCreateVideoDate(new Date());


+ 1
- 0
suimangService/src/main/java/com/iformall/sm/AiPhotoSpeakResult.java View File

@@ -8,6 +8,7 @@ public class AiPhotoSpeakResult {
private boolean success;
private String msg;
private String url;
private String saveDir;

public String getMsgInfo(Integer code, String msg) {
if (code == 4000 && msg.equals("success")) {


+ 63
- 15
suimangService/src/main/java/com/iformall/sm/AiVideoHelper.java View File

@@ -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);
}




+ 9
- 0
suimangService/src/main/java/com/iformall/sm/AiVideoHqParam.java View File

@@ -0,0 +1,9 @@
package com.iformall.sm;

import lombok.Data;

@Data
public class AiVideoHqParam {
private String save_dir;

}

+ 19
- 0
suimangService/src/main/java/com/iformall/sm/AiVideoHqResult.java View File

@@ -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 && msg.equals("success")) {
return "成功";
}
return msg;
}

}

Loading…
Cancel
Save