From 7d9d75004abf47002542b26be62c3c2a4a38b66d Mon Sep 17 00:00:00 2001 From: HuangHai <10402852@qq.com> Date: Tue, 13 May 2025 15:45:31 +0800 Subject: [PATCH] 'commit' --- .../Util/DashScope/DsEmoVideoSynthesis.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/dsAiSupport/src/main/java/com/dsideal/aiSupport/Util/DashScope/DsEmoVideoSynthesis.java b/dsAiSupport/src/main/java/com/dsideal/aiSupport/Util/DashScope/DsEmoVideoSynthesis.java index 73417015..85715ecf 100644 --- a/dsAiSupport/src/main/java/com/dsideal/aiSupport/Util/DashScope/DsEmoVideoSynthesis.java +++ b/dsAiSupport/src/main/java/com/dsideal/aiSupport/Util/DashScope/DsEmoVideoSynthesis.java @@ -34,10 +34,10 @@ public class DsEmoVideoSynthesis { /** * 调用EMO视频合成API * - * @param imageUrl 图片URL - * @param audioUrl 音频URL - * @param faceBbox 人脸边界框 [x, y, width, height] - * @param extBbox 扩展边界框 [x, y, width, height] + * @param imageUrl 图片URL + * @param audioUrl 音频URL + * @param faceBbox 人脸边界框 [x, y, width, height] + * @param extBbox 扩展边界框 [x, y, width, height] * @param styleLevel 风格级别,可选值:normal, strong * @return 任务ID * @throws Exception 异常信息 @@ -96,14 +96,14 @@ public class DsEmoVideoSynthesis { log.info("EMO视频合成响应: {}", responseBody); JSONObject responseJson = JSON.parseObject(responseBody); - + // 获取任务ID String taskId = responseJson.getJSONObject("output").getString("task_id"); log.info("EMO视频合成任务ID: {}", taskId); - + return taskId; } - + /** * 查询任务状态 * @@ -121,7 +121,7 @@ public class DsEmoVideoSynthesis { // 创建请求 Request request = new Request.Builder() - .url(API_URL + taskId) + .url("https://dashscope.aliyuncs.com/api/v1/tasks/" + taskId) .method("GET", null) .addHeader("Authorization", "Bearer " + API_KEY) .build(); @@ -143,7 +143,7 @@ public class DsEmoVideoSynthesis { return JSON.parseObject(responseBody); } - + /** * 下载视频并保存到本地 * @@ -206,7 +206,7 @@ public class DsEmoVideoSynthesis { // 图片URL String imageUrl = "https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/BlogImages/202505131058596.png"; // 音频URL - String audioUrl = "https://dsideal.obs.myhuaweicloud.com/HuangHai/%E5%A4%87%E4%BB%BD/%E5%A4%A7%E5%AE%B6%E5%A5%BD%EF%BC%8C%E8%BF%99%E9%87%8C%E6%98%AF%E6%B5%B7%E5%93%A5AI%E8%AF%BE%E7%A8%8B%EF%BC%8C%E6%88%91%E6%98%AF%E5%B8%AE%E4%BD%A0%E5%AE%9E%E7%8E%B0%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD%E5%8F%98%E7%8E%B0%E7%9A%84%E6%B5%B7%E5%93%A5%E3%80%82.wav"; + String audioUrl = "https://dsideal.obs.myhuaweicloud.com/HuangHai/%E5%A4%87%E4%BB%BD/example.wav"; // 人脸边界框 [x, y, width, height] int[] faceBbox = {10, 20, 30, 40}; // 扩展边界框 [x, y, width, height] @@ -216,7 +216,7 @@ public class DsEmoVideoSynthesis { // 调用EMO视频合成API String taskId = synthesisVideo(imageUrl, audioUrl, faceBbox, extBbox, styleLevel); - + // 轮询查询任务状态 int maxRetries = 100; int retryCount = 0; @@ -225,7 +225,7 @@ public class DsEmoVideoSynthesis { while (retryCount < maxRetries) { JSONObject result = queryTaskStatus(taskId); - String status = result.getJSONObject("output").getString("status"); + String status = result.getJSONObject("output").getString("task_status"); log.info("任务状态: {}", status); if ("SUCCEEDED".equals(status)) { @@ -249,7 +249,7 @@ public class DsEmoVideoSynthesis { if (retryCount >= maxRetries) { log.error("查询任务状态超时,已达到最大重试次数: {}", maxRetries); } - + // 如果获取到了视频URL,则下载保存 if (videoUrl != null && !videoUrl.isEmpty()) { // 创建保存目录 @@ -258,7 +258,7 @@ public class DsEmoVideoSynthesis { String fileName = "emo_" + System.currentTimeMillis() + "_" + taskId + ".mp4"; // 完整保存路径 String savePath = saveDir + "/" + fileName; - + // 下载视频 downloadVideo(videoUrl, savePath); }