index.vue 22.1 KB
Newer Older
Administrator's avatar
Administrator committed
1
<script setup lang="ts">
周成波's avatar
周成波 committed
2 3
import { onMounted, reactive, ref } from "vue";
import { Sunny, UploadFilled } from "@element-plus/icons-vue";
4 5 6 7
import { ElMessage, genFileId,
  type UploadInstance,
  type UploadProps,
  type UploadRawFile } from "element-plus";
周成波's avatar
周成波 committed
8 9
import text2videoService from "@/api/service/text2videoService";
import utils from "@/utils/utils";
周成波's avatar
周成波 committed
10
import { useManyValues } from './compositions/useManyValues'
Administrator's avatar
Administrator committed
11

12
const debug = ref(import.meta.env.MODE === 'production' ? false : true);
周成波's avatar
周成波 committed
13
const loading = ref(false);
14 15
const dialogVisible = ref(false);
const dialogData = ref("");
周成波's avatar
周成波 committed
16
const default_data = useManyValues();
Administrator's avatar
Administrator committed
17
const form = reactive({
周成波's avatar
周成波 committed
18 19
  screen: default_data.screen,
  if_need_subtitle: default_data.if_need_subtitle,
周成波's avatar
周成波 committed
20 21
  chatgpt_prompt: "",
  chatgpt_answer: "",
22
  chatgpt_answer_roles: <Wm.RolesItem[]>[],
23
  all_roles: "",
周成波's avatar
周成波 committed
24 25 26
  adapt_result_json: <Wm.ScriptsItem[]>[],
  task_id: "",
  final_video: "",
Administrator's avatar
Administrator committed
27
});
周成波's avatar
周成波 committed
28 29
const sd_prompt_prefix = default_data.sd_prompt_prefix;
const sd_negative_prompt_prefix = default_data.sd_negative_prompt_prefix;
周成波's avatar
周成波 committed
30

周成波's avatar
周成波 committed
31
const tyqw = {'api': 'tyqw', 'name':'通义千问线上'};
周成波's avatar
周成波 committed
32 33
const baichuan = {'api': 'langchain', 'name':'baichuan2-7b'};
const qwen = {'api': 'langchain', 'name':'Qwen-7B-Chat'};
周成波's avatar
周成波 committed
34
const gpt = {'api': 'gpt', 'name':'chatgpt'};
周成波's avatar
周成波 committed
35 36 37 38 39 40 41 42 43 44 45

const wenan_llm = qwen.api
const wenan_llm_name = qwen.name
const role_llm = tyqw.api
const role_llm_name = tyqw.name
const role_keywords_llm = qwen.api
const role_keywords_llm_name = qwen.name
const tuili_llm = qwen.api
const tuili_llm_name = qwen.name
const fanyi_llm = qwen.api
const fanyi_llm_name = qwen.name
46

周成波's avatar
周成波 committed
47
const voice_rate = ref(-15)
周成波's avatar
周成波 committed
48 49
const voice_volume = ref(0)
const voice = ref("zh-CN-YunjianNeural")
周成波's avatar
周成波 committed
50
const bgm = ref("")
周成波's avatar
周成波 committed
51

52

周成波's avatar
周成波 committed
53
onMounted(() => {
54
  // 初始化示例数据
周成波's avatar
周成波 committed
55
  onChangeScreen(form.screen);
周成波's avatar
周成波 committed
56 57
});

周成波's avatar
周成波 committed
58 59
const delay = (ms: any) => new Promise(res => setTimeout(res, ms));

周成波's avatar
周成波 committed
60 61
const onSubmitGpt = () => {
  text2videoService
62
    .submitGpt(form.chatgpt_prompt, wenan_llm)
周成波's avatar
周成波 committed
63
    .then((result: string) => {
64 65
      console.log(form.chatgpt_prompt);
      console.log(result);
周成波's avatar
周成波 committed
66
      form.chatgpt_answer = result;
周成波's avatar
周成波 committed
67 68 69
    })
    .catch((error: any) => {
      // console.error(error);
Administrator's avatar
Administrator committed
70
      ElMessage({
周成波's avatar
周成波 committed
71
        message: error,
周成波's avatar
周成波 committed
72 73 74 75
        type: "error",
      });
    });
};
周成波's avatar
周成波 committed
76

77 78 79 80 81 82 83 84 85 86
const onAdaptRoles = async () => {
  if (!form.chatgpt_answer || form.chatgpt_answer.length == 0) {
    ElMessage({
      message: "文案不能为空",
      type: "error",
    });
    return;
  }
  loading.value = true;
  // 推理角色
周成波's avatar
周成波 committed
87
  form.chatgpt_answer_roles = [];
88 89 90
  try {
    const adapt_restrict = `
    指令:
周成波's avatar
周成波 committed
91
    请理解这个故事,给出这个故事中的所有角色,多个角色以逗号分隔`;
92 93 94 95
    const roles = await text2videoService.submitGpt("故事:\n" + form.chatgpt_answer + "\n" + adapt_restrict, role_llm);
    form.all_roles = roles.replace(/。/g, '').replace(/、/g, ',')
    console.log(form.all_roles)
    const roles_arr = form.all_roles.split(/[,,]/);
周成波's avatar
周成波 committed
96 97 98 99 100 101 102 103 104 105 106 107 108
    console.log(roles_arr)

    async function processRoles() {
      for (const one_role of roles_arr) {
        await delay(100);
        const adapt_keyword_restrict = `
        指令:
        请理解这个故事,给出这个角色“${one_role.trim()}”的关键词(性别(可以发挥想象进行补充,但一定要有),年龄(可以发挥想象进行补充,但一定要有),
        肤色(可以发挥想象进行补充,但一定要有),衣服(可以发挥想象进行补充,但一定要有),发型(可以发挥想象进行补充,但一定要有),
        发色(可以发挥想象进行补充,但一定要有),脸色(可以发挥想象进行补充,但一定要有),五官特点(可以发挥想象进行补充,但一定要有))。
        要求:
        关键词以逗号分隔。
        只要返回关键词,不需要其他的说明文字。`;
109
        let keywords = await text2videoService.submitGpt("故事:\n" + form.chatgpt_answer + "\n" + adapt_keyword_restrict, role_keywords_llm);
周成波's avatar
周成波 committed
110 111 112
        keywords = keywords.replace(/。/g, '').replace(/、/g, ',')
        form.chatgpt_answer_roles.push({
          "角色": one_role.trim(),
周成波's avatar
周成波 committed
113
          "角色关键词": keywords.trim()+",穿着衣服"
周成波's avatar
周成波 committed
114
        });
115
      }
周成波's avatar
周成波 committed
116 117 118
    }
    try {
      await processRoles();
119
      console.log(form.chatgpt_answer_roles)
周成波's avatar
周成波 committed
120 121 122 123 124 125 126
    } catch (error) {
      ElMessage({
        message: String(error),
        type: "error"
      });
    } finally {
      loading.value = false; // 最终关闭loading(无论成功或失败)
127 128 129 130 131 132 133 134 135 136 137 138
    }
  } catch (error) {
    ElMessage({
      message: String(error),
      type: "error",
    });
  } finally {
    // 最终关闭loading(无论成功或失败)
    loading.value = false;
  }
};

周成波's avatar
周成波 committed
139
const onAdapt = async () => {
周成波's avatar
周成波 committed
140
  if (!form.chatgpt_answer || form.chatgpt_answer.length == 0) {
周成波's avatar
周成波 committed
141
    ElMessage({
周成波's avatar
周成波 committed
142
      message: "文案不能为空",
周成波's avatar
周成波 committed
143 144 145
      type: "error",
    });
    return;
周成波's avatar
周成波 committed
146
  }
周成波's avatar
周成波 committed
147
  loading.value = true;
周成波's avatar
周成波 committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
  form.task_id = utils.genDateTimeStr();
  console.log(form.task_id)
  // 按标点拆分成分镜
  const sentences = utils.splitText(form.chatgpt_answer);
  console.log(sentences.length)
  // 分镜
  form.adapt_result_json = []
  for (let i = 0; i < sentences.length; i++) {
    form.adapt_result_json.push({
      "编号": (i + 1).toString(),
      "场景描述": sentences[i].trim(),
      "场景关键词": "",
      "角色": "",
      "角色关键词": "",
      "画面描述词": "",
周成波's avatar
周成波 committed
163
      "本镜配图": "src/assets/loading.gif",
周成波's avatar
周成波 committed
164 165 166 167
      "local_image_path": "",
    });
  }
  console.log(form.adapt_result_json)
168 169 170 171

  async function processScenes() {
    for (const item of form.adapt_result_json) {
      await onAdaptOne(item);
周成波's avatar
周成波 committed
172 173 174
      // await delay(100);
      // await onDrawOne(item);
      onDrawOne(item);
175 176 177
    }
  }

周成波's avatar
周成波 committed
178
  try {
179
    await processScenes();
周成波's avatar
周成波 committed
180
    ElMessage({
181 182
      message: "all scene ok",
      type: "success"
周成波's avatar
周成波 committed
183
    });
周成波's avatar
周成波 committed
184
    console.log(form.adapt_result_json);
周成波's avatar
周成波 committed
185
  } catch (error) {
周成波's avatar
周成波 committed
186
    ElMessage({
周成波's avatar
周成波 committed
187
      message: String(error),
188
      type: "error"
周成波's avatar
周成波 committed
189
    });
周成波's avatar
周成波 committed
190
  } finally {
191
    loading.value = false; // 最终关闭loading(无论成功或失败)
周成波's avatar
周成波 committed
192
  }
193

周成波's avatar
周成波 committed
194
};
周成波's avatar
周成波 committed
195

周成波's avatar
周成波 committed
196 197 198 199 200 201 202 203 204 205
const onAdaptOne = async (item: any) => {
  if (!item.场景描述) {
    ElMessage({
      message: "分镜场景描述不能为空",
      type: "error",
    });
    return;
  }
  // 推理关键词
  try {
206 207
    const adapt_restrict = `
    指令:
周成波's avatar
周成波 committed
208 209 210
    请理解这个故事,给出这个场景“${item.场景描述}”的关键词(年代(可以发挥想象进行补充,但一定要有),空间(可以发挥想象进行补充,但一定要有),
    时间段(可以发挥想象进行补充,但一定要有),地理环境(可以发挥想象进行补充,但一定要有),天气(可以发挥想象进行补充,但一定要有),
    物品(可以发挥想象进行补充,但一定要有),人物(可以发挥想象进行补充,但一定要有),镜头角度(可以发挥想象进行补充,但一定要有))。
211
    要求:
周成波's avatar
周成波 committed
212 213 214
    关键词以逗号分隔。
    只要返回关键词,不需要其他的说明文字。`;
    const keywords = await text2videoService.submitGpt("故事:\n" + form.chatgpt_answer + "\n" + adapt_restrict, tuili_llm);
周成波's avatar
周成波 committed
215
    // console.log(keywords)
周成波's avatar
周成波 committed
216 217 218 219 220
    item.场景关键词 = keywords;
    if (form.chatgpt_answer_roles.length === 0) {
      // 总角色为空
      item.角色 = '';
      item.角色关键词 = '';
221
    } else {
周成波's avatar
周成波 committed
222
      // 总角色不为空
周成波's avatar
周成波 committed
223 224 225 226 227
      const adapt_role_restrict = `
      指令:
      请理解这个故事,针对其中的这个场景:“${item.场景描述}”,从所有角色中选择本场景的角色,多个角色以逗号分隔。`;
      const item_roles = await text2videoService.submitGpt("故事:\n" + form.chatgpt_answer + "\n所有角色:\n"+ form.all_roles +"\n" + adapt_role_restrict, tuili_llm);
      // console.log(role_keywords)
周成波's avatar
周成波 committed
228 229 230 231 232 233 234 235 236
      item.角色 = item_roles;
      let role_kws = ""
      const item_roles_arr = item_roles.split(/[,,]/);
      item_roles_arr.forEach( one_item_role => {
        // 人工指定角色关键词,包含则取
        form.chatgpt_answer_roles.forEach(i => {
          if (i["角色"].includes(one_item_role.trim()) || one_item_role.includes(i["角色"].trim())) {
            role_kws = `${role_kws}${i["角色"]}${i["角色关键词"]}】`
          }
237
        })
周成波's avatar
周成波 committed
238 239
      })
      item.角色关键词 = role_kws;
240
    }
周成波's avatar
周成波 committed
241 242 243 244
  } catch (error) {
    ElMessage({
      message: String(error),
      type: "error",
周成波's avatar
周成波 committed
245
    });
周成波's avatar
周成波 committed
246
  }
周成波's avatar
周成波 committed
247 248
};

周成波's avatar
周成波 committed
249
const onDrawOne = async (item: any) => {
250
  if (!item.场景描述 && !item.场景关键词) {
周成波's avatar
周成波 committed
251
    ElMessage({
252
      message: "场景描述和场景关键词不能都为空",
周成波's avatar
周成波 committed
253 254 255 256 257
      type: "error",
    });
    return;
  }
  // 翻译+画图
周成波's avatar
周成波 committed
258 259 260
  if (!form.task_id) {
    form.task_id = utils.genDateTimeStr();
    console.log(form.task_id)
周成波's avatar
周成波 committed
261 262
  }
  try {
周成波's avatar
周成波 committed
263
    item.本镜配图 = "src/assets/loading.gif";
264 265 266 267 268
    let temp_prompt = ""
    if (item.场景描述) {temp_prompt = temp_prompt + `场景描述为:${item.场景描述}\n`};
    if (item.场景关键词) {temp_prompt = temp_prompt + `场景关键词为:${item.场景关键词}\n`};
    if (item.角色) {temp_prompt = temp_prompt + `场景中的角色有:${item.角色}\n`};
    if (item.角色关键词) {temp_prompt = temp_prompt + `角色关键词为:${item.角色关键词}\n`};
周成波's avatar
周成波 committed
269
    const sd_describe = await text2videoService.submitGpt(
270
      `${temp_prompt}
271
      指令:
272
      请理解以上内容,并返回一段英文的描述。`, fanyi_llm
周成波's avatar
周成波 committed
273 274 275
    );
    item.画面描述词 = sd_describe;
    const sd_prompt = item.画面描述词 + "," + sd_prompt_prefix;
周成波's avatar
周成波 committed
276 277 278 279 280 281
    let width = "960";
    let height = "540";
    if (form.screen == "竖屏") {
      width = "540";
      height = "960";
    }
282 283
    // console.log(sd_prompt);
    // console.log(sd_negative_prompt_prefix);
284 285 286 287 288
    const sampler_index = "DPM++ SDE Karras";
    const seed = "-1";
    const steps = "6";
    const cfg_scale = "2";
    const sd_img = await text2videoService.submitSD(form.task_id, item.编号, sd_prompt, sd_negative_prompt_prefix, width, height, sampler_index, seed, steps, cfg_scale);
周成波's avatar
周成波 committed
289 290 291 292 293 294 295
    item.本镜配图 = sd_img.domain_image_path+"?v="+utils.genDateTimeStr();
    item.local_image_path = sd_img.local_image_path;
  } catch (error) {
    ElMessage({
      message: String(error),
      type: "error",
    });
周成波's avatar
周成波 committed
296
    item.本镜配图 = ""
周成波's avatar
周成波 committed
297 298 299
  }
};

周成波's avatar
周成波 committed
300
const onGenVideo = () => {
周成波's avatar
周成波 committed
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
  if (!form.adapt_result_json || form.adapt_result_json.length == 0 ) {
    ElMessage({
      message: "必要信息不能为空,请重新执行",
      type: "error",
    });
    return;
  }
  let is_all_ok = true;
  form.adapt_result_json.map(item => {
    if (item.编号 == "" || item.场景描述 == "" || item.local_image_path == "") {
      ElMessage({
        message: `分镜 ${item.编号} 的必要信息为空,请重新执行`,
        type: "error",
      });
      is_all_ok = false;
    }
  });
  if (!is_all_ok) return;
周成波's avatar
周成波 committed
319
  console.log(form.adapt_result_json);
周成波's avatar
周成波 committed
320
  const video_param_detail = form.adapt_result_json.map(item => {
周成波's avatar
周成波 committed
321 322 323
    return {
      idx: item.编号,
      text: item.场景描述,
周成波's avatar
周成波 committed
324
      img_path: item.local_image_path
周成波's avatar
周成波 committed
325 326
    };
  });
周成波's avatar
周成波 committed
327 328 329 330
  let para_rate = `${voice_rate.value}%`;
  let para_volume = `${voice_volume.value}%`;
  if(voice_rate.value >= 0){para_rate = `+${para_rate}`}
  if(voice_volume.value >= 0){para_volume = `+${para_volume}`}
周成波's avatar
周成波 committed
331
  const video_param = {
周成波's avatar
周成波 committed
332
    task_id: form.task_id,
周成波's avatar
周成波 committed
333
    if_need_subtitle: form.if_need_subtitle,
周成波's avatar
周成波 committed
334
    lang: "zh",
周成波's avatar
周成波 committed
335
    task_info: video_param_detail,
周成波's avatar
周成波 committed
336 337 338 339
    rate: para_rate,
    volume: para_volume,
    voice: voice.value,
    bgm: bgm.value,
周成波's avatar
周成波 committed
340
  }
周成波's avatar
周成波 committed
341 342 343
  text2videoService
    .submitGenVideo(video_param)
    .then((result: string) => {
周成波's avatar
周成波 committed
344
      console.log(result);
周成波's avatar
周成波 committed
345 346
      form.final_video = "";
      form.final_video = result+"?v="+utils.genDateTimeStr();
朱国瑞's avatar
朱国瑞 committed
347
    })
周成波's avatar
周成波 committed
348 349 350 351 352 353 354 355
    .catch((error: any) => {
      // console.error(error);
      ElMessage({
        message: error,
        type: "error",
      });
    });
};
周成波's avatar
周成波 committed
356 357 358 359

const clean_demo = () => {
  form.chatgpt_prompt = "";
  form.chatgpt_answer = "";
360
  form.chatgpt_answer_roles = <Wm.RolesItem[]>[];
周成波's avatar
周成波 committed
361 362 363 364
  form.adapt_result_json = <Wm.ScriptsItem[]>[];
  form.task_id = "";
  form.final_video = "";
}
周成波's avatar
周成波 committed
365

366 367 368 369
const clean_roles = () => {
  form.chatgpt_answer_roles = <Wm.RolesItem[]>[];
}

周成波's avatar
周成波 committed
370 371 372 373 374 375
const onChangeScreen = (val: string) => {
  if (debug.value == true) {
    if (val == "横屏") {
      form.task_id = default_data.horizontal_data.task_id;
      form.chatgpt_prompt = default_data.horizontal_data.chatgpt_prompt;
      form.chatgpt_answer = default_data.horizontal_data.chatgpt_answer;
376
      form.chatgpt_answer_roles = default_data.horizontal_data.chatgpt_answer_roles;
周成波's avatar
周成波 committed
377 378 379 380 381 382
      form.adapt_result_json = default_data.horizontal_data.adapt_result_json;
      form.final_video = default_data.horizontal_data.final_video;
    } else {
      form.task_id = default_data.vertical_data.task_id;
      form.chatgpt_prompt = default_data.vertical_data.chatgpt_prompt;
      form.chatgpt_answer = default_data.vertical_data.chatgpt_answer;
383
      form.chatgpt_answer_roles = default_data.vertical_data.chatgpt_answer_roles;
周成波's avatar
周成波 committed
384 385 386 387 388
      form.adapt_result_json = default_data.vertical_data.adapt_result_json;
      form.final_video = default_data.vertical_data.final_video;
    }
  }
}
389

390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
const showsdprompt = (item: any) => {
  // alert(item.画面描述词)
  dialogData.value = item.画面描述词+ "," +sd_prompt_prefix+'===== negative ====='+sd_negative_prompt_prefix;
  dialogVisible.value = true; // 打开对话框
}

const upload = ref<UploadInstance>()

const actionUrl = ref(
  import.meta.env.MODE === 'production'
    ? '/file'
    : import.meta.env.VITE_APP_BASE_API + '/file'
)

const handleUploadSuccess = (val: Wm.UploadResult) => {
  if (val.code == 0){
    // console.log(val)
    const id = parseInt(val.message) - 1;
    form.adapt_result_json[id].本镜配图 = val.data[0].url+"?v="+utils.genDateTimeStr();
周成波's avatar
周成波 committed
409
    form.adapt_result_json[id].local_image_path = val.data[0].path;
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427
    ElMessage({
      message: '上传成功',
      type: 'success'
    })
  } else {
    ElMessage({
      message: '上传失败',
      type: 'error'
    })
  }
}

const handleExceed: UploadProps['onExceed'] = (files) => {
  upload.value!.clearFiles()
  const file = files[0] as UploadRawFile
  file.uid = genFileId()
  upload.value!.handleStart(file)
  upload.value!.submit()
428
}
Administrator's avatar
Administrator committed
429 430 431 432
</script>

<template>
  <main class="home-container">
周成波's avatar
周成波 committed
433
    <!-- 标题 -->
Administrator's avatar
Administrator committed
434
    <el-divider content-position="left">text2video</el-divider>
周成波's avatar
周成波 committed
435
    <el-form :model="form" label-width="114px" v-loading="loading">
周成波's avatar
周成波 committed
436 437 438 439 440 441 442 443
      <el-form-item>
        <div>
          <el-radio-group v-model="form.screen" @change="onChangeScreen">
            <el-radio label="横屏" size="large" border/>
            <el-radio label="竖屏" size="large" border/>
          </el-radio-group>
        </div>
      </el-form-item>
周成波's avatar
周成波 committed
444
      <el-form-item>
445
        <el-button type="success" @click="clean_demo">清除所有数据</el-button>
周成波's avatar
周成波 committed
446
      </el-form-item>
周成波's avatar
周成波 committed
447
      <!-- Prompt到文案 -->
448
      <el-form-item label="Prompt">
周成波's avatar
周成波 committed
449
        <el-input v-model="form.chatgpt_prompt" :autosize="true" type="textarea" />
Administrator's avatar
Administrator committed
450
      </el-form-item>
周成波's avatar
周成波 committed
451
      <el-form-item>
452
        <el-button type="primary" @click="onSubmitGpt">生成文案({{wenan_llm_name}}</el-button>
周成波's avatar
周成波 committed
453
      </el-form-item>
周成波's avatar
周成波 committed
454
      <el-form-item label="文案">
朱国瑞's avatar
朱国瑞 committed
455
        <el-input v-model="form.chatgpt_answer" :autosize="true" type="textarea" />
周成波's avatar
周成波 committed
456
      </el-form-item>
457 458
      <!-- 角色 -->
      <el-form-item>
周成波's avatar
周成波 committed
459
        <el-button type="primary" @click="onAdaptRoles">推理角色({{role_llm_name}})、推理角色关键词({{role_keywords_llm_name}}</el-button>
460
        <el-button plain @click="clean_roles">清空总角色列表</el-button>
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475
      </el-form-item>
      <el-form-item label="角色">
        <el-table :data="form.chatgpt_answer_roles" border style="width: 100%; z-index: calc(var(--el-table-index) -1)">
          <el-table-column prop="角色" label="角色">
            <template v-slot="scope">
              <el-input v-model="scope.row.角色" :autosize="true" type="textarea"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="角色关键词" label="角色关键词">
            <template v-slot="scope">
              <el-input v-model="scope.row.角色关键词" :autosize="true" type="textarea"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
周成波's avatar
周成波 committed
476
      <!-- 分镜 -->
Administrator's avatar
Administrator committed
477
      <el-form-item>
周成波's avatar
周成波 committed
478
        <el-button type="primary" @click="onAdapt">分镜、推理场景关键词({{tuili_llm_name}})、英文描述({{fanyi_llm_name}})、绘图</el-button>
周成波's avatar
周成波 committed
479
      </el-form-item>
周成波's avatar
周成波 committed
480 481
      <el-form-item label="分镜">
        <el-table :data="form.adapt_result_json" border style="width: 100%; z-index: calc(var(--el-table-index) -1)">
朱国瑞's avatar
朱国瑞 committed
482
          <el-table-column prop="编号" label="编号" width="60" />
周成波's avatar
周成波 committed
483 484
          <el-table-column prop="场景描述" label="场景描述">
            <template v-slot="scope">
朱国瑞's avatar
朱国瑞 committed
485
              <el-input v-model="scope.row.场景描述" :autosize="true" type="textarea"></el-input>
周成波's avatar
周成波 committed
486 487 488 489
            </template>
          </el-table-column>
          <el-table-column prop="场景关键词" label="场景关键词">
            <template v-slot="scope">
朱国瑞's avatar
朱国瑞 committed
490
              <el-input v-model="scope.row.场景关键词" :autosize="true" type="textarea"></el-input>
周成波's avatar
周成波 committed
491 492 493 494
            </template>
          </el-table-column>
          <el-table-column prop="角色" label="角色">
            <template v-slot="scope">
朱国瑞's avatar
朱国瑞 committed
495
              <el-input v-model="scope.row.角色" :autosize="true" type="textarea"></el-input>
周成波's avatar
周成波 committed
496 497 498 499
            </template>
          </el-table-column>
          <el-table-column prop="角色关键词" label="角色关键词">
            <template v-slot="scope">
朱国瑞's avatar
朱国瑞 committed
500
              <el-input v-model="scope.row.角色关键词" :autosize="true" type="textarea"></el-input>
周成波's avatar
周成波 committed
501 502
            </template>
          </el-table-column>
周成波's avatar
周成波 committed
503
          <el-table-column prop="本镜配图" label="本镜配图" width="300">
周成波's avatar
周成波 committed
504 505
            <template v-slot="scope">
              <div>
周成波's avatar
周成波 committed
506
                <el-image :src="scope.row.本镜配图" :zoom-rate="1.2" :max-scale="1.5" :min-scale="0.5"
周成波's avatar
周成波 committed
507 508
                  :preview-src-list="[scope.row.本镜配图]" fit="cover" :hide-on-click-modal="true"
                />
周成波's avatar
周成波 committed
509 510 511
              </div>
            </template>
          </el-table-column>
周成波's avatar
周成波 committed
512 513 514 515 516 517
          <el-table-column width="120" label="操作" align="center">
            <!-- 
            <template v-slot:header>
              <el-button type="danger" size="default" @click="">批量绘制所有图片</el-button>
            </template> 
            -->
周成波's avatar
周成波 committed
518
            <template v-slot="scope">
519 520
              <div style="margin: 10px 0"><el-button type="primary" size="default" @click="onAdaptOne(scope.row)">推理关键词</el-button></div>
              <div style="margin: 10px 0"><el-button type="primary" size="default" @click="onDrawOne(scope.row)">翻译、绘图</el-button></div>
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
              <el-upload
                class="upload-demo"
                ref="upload"
                list-type="picture"
                :show-file-list="false"
                :limit="1"
                :action="actionUrl"
                :on-success="handleUploadSuccess"
                :on-exceed="handleExceed"
                :data="{item_id: scope.row.编号}"
              >
                <el-button type="primary">上传图片</el-button>
              </el-upload>
              <div style="margin: 10px 0"><el-button plain @click="showsdprompt(scope.row)">debug</el-button></div>
              <el-dialog
                v-model=dialogVisible
                width="80%"
              >
                <p>{{ dialogData }}</p>
                <template #footer>
                  <div class="dialog-footer">
                    <el-button type="primary" @click="dialogVisible = false">ok</el-button>
                  </div>
                </template>
              </el-dialog>
周成波's avatar
周成波 committed
546 547 548 549
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
周成波's avatar
周成波 committed
550
      <!-- 生成视频 -->
周成波's avatar
周成波 committed
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
      <el-form-item label="设置">
        <span style="margin: 0 20px">语速:</span>
        <el-slider v-model="voice_rate" show-input :min="-50" :max="50" :marks="default_data.marks" style="width: 900px" />
      </el-form-item>
      <el-form-item>
        <span style="margin: 0 20px">音量:</span>
        <el-slider v-model="voice_volume" show-input :min="-80" :max="80" :marks="default_data.marks" style="width: 900px" />
      </el-form-item>
      <el-form-item>
        <span style="margin: 20px 20px 0 20px">语音:</span>
        <el-select v-model="voice" placeholder="Select" style="width: 400px; margin-top: 20px;">
          <el-option
            v-for="item in default_data.voices"
            :key="item.value"
            :label="item.value"
            :value="item.value"
          >
            <span style="float: left">{{ item.value }}</span>
            <span
              style="
                float: right;
                color: var(--el-text-color-secondary);
                font-size: 13px;
              "
              >{{ item.label }}</span>
          </el-option>
        </el-select>
        <audio :src="'src/assets/edge-tts-voices/' + voice + '.mp3'" controls style="height: 30px; margin: 20px 0 0 10px;"></audio>
      </el-form-item>
      <el-form-item>
        <span style="margin: 0 20px">背景:</span>
        <el-select v-model="bgm" placeholder="无" style="width: 400px;">
          <el-option
            v-for="item in default_data.bgm"
            :key="item.value"
            :label="item.value"
            :value="item.value"
          >
            <span style="float: left">{{ item.label }}</span>
            <span
              style="
                float: right;
                color: var(--el-text-color-secondary);
                font-size: 13px;
              "
              >{{ item.value }}</span>
          </el-option>
        </el-select>
        <audio :src="'src/assets/bgm/' + bgm + '.mp3'" controls style="height: 30px; margin-left:10px;"></audio>
      </el-form-item>
周成波's avatar
周成波 committed
601
      <el-form-item>
周成波's avatar
周成波 committed
602
        <el-button type="primary" @click="onGenVideo">生成视频</el-button>
周成波's avatar
周成波 committed
603
      </el-form-item>
周成波's avatar
周成波 committed
604 605 606
      <el-form-item>
        <video :src="form.final_video" controls></video>
      </el-form-item>
Administrator's avatar
Administrator committed
607 608 609
    </el-form>
  </main>
</template>
Administrator's avatar
Administrator committed
610

Administrator's avatar
Administrator committed
611
<style lang="scss" scoped>
朱国瑞's avatar
朱国瑞 committed
612 613 614 615 616 617 618 619 620
.home-container {
  width: 100%;
}
</style>

<style lang="scss">
.home-container {
  .el-table .el-table__cell {
    z-index: calc(var(--el-table-index) -1);
周成波's avatar
周成波 committed
621
  }
朱国瑞's avatar
朱国瑞 committed
622
}
Administrator's avatar
Administrator committed
623
</style>