|
|
@ -103,21 +103,21 @@ public class ImgSpeak {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 调用灵动人像LivePortrait视频合成API
|
|
|
|
* 调用灵动人像LivePortrait视频合成API
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param imageUrl 图片URL
|
|
|
|
* @param imageUrl 图片URL
|
|
|
|
* @param audioUrl 音频URL
|
|
|
|
* @param audioUrl 音频URL
|
|
|
|
* @param templateId 模板ID,可选值:normal, dance, rap等
|
|
|
|
* @param templateId 模板ID,可选值:normal, dance, rap等
|
|
|
|
* @param eyeMoveFreq 眼睛移动频率,范围0-1
|
|
|
|
* @param eyeMoveFreq 眼睛移动频率,范围0-1
|
|
|
|
* @param videoFps 视频帧率,默认30
|
|
|
|
* @param videoFps 视频帧率,默认30
|
|
|
|
* @param mouthMoveStrength 嘴部动作强度,范围0-1
|
|
|
|
* @param mouthMoveStrength 嘴部动作强度,范围0-1
|
|
|
|
* @param pasteBack 是否贴回原图,true或false
|
|
|
|
* @param pasteBack 是否贴回原图,true或false
|
|
|
|
* @param headMoveStrength 头部动作强度,范围0-1
|
|
|
|
* @param headMoveStrength 头部动作强度,范围0-1
|
|
|
|
* @return 任务ID
|
|
|
|
* @return 任务ID
|
|
|
|
* @throws Exception 异常信息
|
|
|
|
* @throws Exception 异常信息
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@SneakyThrows
|
|
|
|
@SneakyThrows
|
|
|
|
public static String synthesisVideo(String imageUrl, String audioUrl, String templateId,
|
|
|
|
public static String synthesisVideo(String imageUrl, String audioUrl, String templateId,
|
|
|
|
double eyeMoveFreq, int videoFps, double mouthMoveStrength,
|
|
|
|
double eyeMoveFreq, int videoFps, double mouthMoveStrength,
|
|
|
|
boolean pasteBack, double headMoveStrength) {
|
|
|
|
boolean pasteBack, double headMoveStrength) {
|
|
|
|
// 先进行人脸检测
|
|
|
|
// 先进行人脸检测
|
|
|
|
detectFace(imageUrl);
|
|
|
|
detectFace(imageUrl);
|
|
|
|
|
|
|
|
|
|
|
@ -303,7 +303,7 @@ public class ImgSpeak {
|
|
|
|
|
|
|
|
|
|
|
|
// 调用灵动人像LivePortrait视频合成API
|
|
|
|
// 调用灵动人像LivePortrait视频合成API
|
|
|
|
String taskId = synthesisVideo(imageUrl, audioUrl, templateId, eyeMoveFreq,
|
|
|
|
String taskId = synthesisVideo(imageUrl, audioUrl, templateId, eyeMoveFreq,
|
|
|
|
videoFps, mouthMoveStrength, pasteBack, headMoveStrength);
|
|
|
|
videoFps, mouthMoveStrength, pasteBack, headMoveStrength);
|
|
|
|
|
|
|
|
|
|
|
|
// 轮询查询任务状态
|
|
|
|
// 轮询查询任务状态
|
|
|
|
int maxRetries = 100;
|
|
|
|
int maxRetries = 100;
|
|
|
@ -325,7 +325,6 @@ public class ImgSpeak {
|
|
|
|
double videoDuration = result.getJSONObject("usage").getDoubleValue("video_duration");
|
|
|
|
double videoDuration = result.getJSONObject("usage").getDoubleValue("video_duration");
|
|
|
|
String videoRatio = result.getJSONObject("usage").getString("video_ratio");
|
|
|
|
String videoRatio = result.getJSONObject("usage").getString("video_ratio");
|
|
|
|
log.info("视频时长: {}秒, 视频比例: {}", videoDuration, videoRatio);
|
|
|
|
log.info("视频时长: {}秒, 视频比例: {}", videoDuration, videoRatio);
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
} else if ("FAILED".equals(status)) {
|
|
|
|
} else if ("FAILED".equals(status)) {
|
|
|
|
// 任务失败
|
|
|
|
// 任务失败
|
|
|
|