index_en.vue 25.1 KB
Newer Older
周成波's avatar
周成波 committed
1 2 3
<script setup lang="ts">
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 10 11
import text2videoService from "@/api/service/text2videoService";
import utils from "@/utils/utils";
import { useManyValues } from './compositions/useManyValues'

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 17 18 19 20 21 22
const default_data = useManyValues();
const form = reactive({
  screen: default_data.screen,
  if_need_subtitle: default_data.if_need_subtitle,
  chatgpt_prompt: "",
  chatgpt_answer: "",
  chatgpt_answer_roles: <Wm.RolesItem[]>[],
23
  all_roles: "",
周成波's avatar
周成波 committed
24 25 26 27 28 29 30
  adapt_result_json: <Wm.ScriptsItem[]>[],
  task_id: "",
  final_video: "",
});
const sd_prompt_prefix = default_data.sd_prompt_prefix;
const sd_negative_prompt_prefix = default_data.sd_negative_prompt_prefix;

周成波's avatar
周成波 committed
31
const tyqw = {'api': 'tyqw', 'name':'通义千问线上'};
Administrator's avatar
Administrator 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'};
Administrator's avatar
Administrator committed
35

周成波's avatar
周成波 committed
36 37 38 39 40 41 42 43 44 45
const wenan_llm = gpt.api
const wenan_llm_name = gpt.name
const role_llm = gpt.api
const role_llm_name = gpt.name
const role_keywords_llm = gpt.api
const role_keywords_llm_name = gpt.name
const tuili_llm = gpt.api
const tuili_llm_name = gpt.name
const fanyi_llm = gpt.api
const fanyi_llm_name = gpt.name
Administrator's avatar
Administrator committed
46

周成波's avatar
周成波 committed
47
const voice_rate = ref(-10)
48 49
const voice_volume = ref(0)
const voice = ref("en-US-BrianNeural")
周成波's avatar
周成波 committed
50
const bgm = ref("解忧曲")
51 52 53
const bgm_volume = ref(0.3)
const pwdCheckDialogVisible = ref(false);
const pwdCheckValue = ref("")
周成波's avatar
周成波 committed
54
const sub_font_color = ref("#FFFF00")
周成波's avatar
周成波 committed
55 56
const sub_font_size = ref(25)
const sub_position = ref(0.4)
57

Administrator's avatar
Administrator committed
58

周成波's avatar
周成波 committed
59
onMounted(() => {
60
  // 初始化示例数据
周成波's avatar
周成波 committed
61
  onChangeScreen(form.screen);
62 63 64 65 66 67
  // 初始化密码框
  if (debug.value == true) {
    pwdCheckDialogVisible.value = false;
  } else {
    pwdCheckDialogVisible.value = true;
  }
周成波's avatar
周成波 committed
68 69
});

Administrator's avatar
Administrator committed
70 71
const delay = (ms: any) => new Promise(res => setTimeout(res, ms));

周成波's avatar
周成波 committed
72 73
const onSubmitGpt = () => {
  text2videoService
周成波's avatar
周成波 committed
74
    .submitLLM(form.chatgpt_prompt, wenan_llm)
周成波's avatar
周成波 committed
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
    .then((result: string) => {
      console.log(form.chatgpt_prompt);
      console.log(result);
      form.chatgpt_answer = result;
    })
    .catch((error: any) => {
      // console.error(error);
      ElMessage({
        message: error,
        type: "error",
      });
    });
};

const onAdaptRoles = async () => {
  if (!form.chatgpt_answer || form.chatgpt_answer.length == 0) {
    ElMessage({
      message: "文案不能为空",
      type: "error",
    });
    return;
  }
  loading.value = true;
  // 推理角色
Administrator's avatar
Administrator committed
99
  form.chatgpt_answer_roles = [];
周成波's avatar
周成波 committed
100 101 102
  try {
    const adapt_restrict = `
    Instructions:
Administrator's avatar
Administrator committed
103
    Please understand this story and provide all the characters in it, with multiple characters separated by commas`;
周成波's avatar
周成波 committed
104
    const roles = await text2videoService.submitLLM("story:\n" + form.chatgpt_answer + "\n" + adapt_restrict, role_llm);
105 106 107
    form.all_roles = roles.replace(/。/g, '').replace(/、/g, ',')
    console.log(form.all_roles)
    const roles_arr = form.all_roles.split(/[,,]/);
Administrator's avatar
Administrator committed
108 109 110 111 112 113 114 115 116 117 118 119 120
    console.log(roles_arr)

    async function processRoles() {
      for (const one_role of roles_arr) {
        await delay(100);
        const adapt_keyword_restrict = `
        Instructions:
        Please understand this story and provide the keywords for the character "${one_role.trim()}" (gender (can be supplemented with imagination, but must have it), age (can be supplemented with imagination, but must have it),
        Skin color (can be supplemented with imagination, but must have it), clothing (can be supplemented with imagination, but must have it), hairstyle (can be supplemented with imagination, but must have it),
        Hair color (can be supplemented with imagination, but must have it), facial color (can be supplemented with imagination, but must have it), facial features (can be supplemented with imagination, but must have it).
        Requirement:
        Keywords are separated by commas.
        As long as the keyword is returned, no additional explanatory text is required.`;
周成波's avatar
周成波 committed
121
        let keywords = await text2videoService.submitLLM("story:\n" + form.chatgpt_answer + "\n" + adapt_keyword_restrict, role_keywords_llm);
Administrator's avatar
Administrator committed
122 123 124
        keywords = keywords.replace(/。/g, '').replace(/、/g, ',')
        form.chatgpt_answer_roles.push({
          "角色": one_role.trim(),
周成波's avatar
周成波 committed
125 126 127
          "角色关键词": keywords.trim()+",dressed",
          "角色英文关键词": "",
          "属性": "",
Administrator's avatar
Administrator committed
128 129 130 131 132 133 134 135 136 137 138 139 140
        });
      }
    }
    try {
      await processRoles();
      console.log(form.chatgpt_answer_roles)
    } catch (error) {
      ElMessage({
        message: String(error),
        type: "error"
      });
    } finally {
      loading.value = false; // 最终关闭loading(无论成功或失败)
周成波's avatar
周成波 committed
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
    }
  } catch (error) {
    ElMessage({
      message: String(error),
      type: "error",
    });
  } finally {
    // 最终关闭loading(无论成功或失败)
    loading.value = false;
  }
};

const onAdapt = async () => {
  if (!form.chatgpt_answer || form.chatgpt_answer.length == 0) {
    ElMessage({
      message: "文案不能为空",
      type: "error",
    });
    return;
  }
  loading.value = true;
  form.task_id = utils.genDateTimeStr();
  console.log(form.task_id)
  // 按标点拆分成分镜
  const sentences = utils.splitTextEn(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
177
      "本镜配图": "src/assets/loading.gif",
周成波's avatar
周成波 committed
178 179 180 181 182 183 184 185
      "local_image_path": "",
    });
  }
  console.log(form.adapt_result_json)

  async function processScenes() {
    for (const item of form.adapt_result_json) {
      await onAdaptOne(item);
周成波's avatar
周成波 committed
186 187 188
      // await delay(100);
      // await onDrawOne(item);
      onDrawOne(item);
周成波's avatar
周成波 committed
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
    }
  }

  try {
    await processScenes();
    ElMessage({
      message: "all scene ok",
      type: "success"
    });
    console.log(form.adapt_result_json);
  } catch (error) {
    ElMessage({
      message: String(error),
      type: "error"
    });
  } finally {
    loading.value = false; // 最终关闭loading(无论成功或失败)
  }

};

const onAdaptOne = async (item: any) => {
  if (!item.场景描述) {
    ElMessage({
      message: "分镜场景描述不能为空",
      type: "error",
    });
    return;
  }
  // 推理关键词
  try {
    const adapt_restrict = `
    Instructions:
Administrator's avatar
Administrator committed
222 223 224
    Please understand this story and provide the keywords for the scene "${item.场景描述}" (era (can be supplemented with imagination, but must be present), space (can be supplemented with imagination, but must be present),
    Time period (imagination can be used to supplement, but it must be present), geographical environment (imagination can be used to supplement, but it must be present), weather (imagination can be used to supplement, but it must be present),
    Items (can be supplemented with imagination, but must be present), characters (can be supplemented with imagination, but must be present), camera angles (can be supplemented with imagination, but must be present).
周成波's avatar
周成波 committed
225
    Requirement:
Administrator's avatar
Administrator committed
226 227
    Keywords are separated by commas.
    As long as the keyword is returned, no additional explanatory text is required.`;
周成波's avatar
周成波 committed
228
    const keywords = await text2videoService.submitLLM("story:\n" + form.chatgpt_answer +  "\n" + adapt_restrict, tuili_llm);
周成波's avatar
周成波 committed
229
    // console.log(keywords)
Administrator's avatar
Administrator committed
230
    item.场景关键词 = keywords;
231 232 233 234 235 236
    if (form.chatgpt_answer_roles.length === 0) {
      // 总角色为空
      item.角色 = '';
      item.角色关键词 = '';
    } else {
      // 总角色不为空
周成波's avatar
周成波 committed
237 238 239
      const adapt_role_restrict = `
      Instructions:
      Please understand this story and for the scene: "${item.场景描述}", select the character in this scene from characters, with multiple characters separated by commas.`;
周成波's avatar
周成波 committed
240
      const item_roles = await text2videoService.submitLLM("story:\n" + form.chatgpt_answer + "\ncharacters:\n"+ form.all_roles +"\n" + adapt_role_restrict, tuili_llm);
周成波's avatar
周成波 committed
241
      // console.log(role_keywords)
Administrator's avatar
Administrator committed
242 243
      item.角色 = item_roles;
      let role_kws = ""
244
      const item_roles_arr = item_roles.split(/[,,、]/);
Administrator's avatar
Administrator committed
245
      item_roles_arr.forEach( one_item_role => {
246 247 248 249 250 251 252
        let temp_role_kws = ""
        // 人工匹配角色关键词,先找想同的
        for (const i of form.chatgpt_answer_roles) {
          if (i["角色"].trim() == one_item_role.trim()) {
            temp_role_kws = `[${i["角色"]}: ${i["角色关键词"]}]`;
            // 找到就ok
            break;
Administrator's avatar
Administrator committed
253
          }
254 255 256 257 258 259 260 261 262 263 264 265
        }
        // 如果找不到相同的,则模糊匹配
        if (! temp_role_kws) {
          for (const i of form.chatgpt_answer_roles) {
            if (i["角色"].includes(one_item_role.trim()) || one_item_role.includes(i["角色"].trim())) {
              temp_role_kws = `[${i["角色"]}: ${i["角色关键词"]}]`;
              // 匹配到一个就ok
              break;
            }
          }
        }
        role_kws = `${role_kws}${temp_role_kws}`;
Administrator's avatar
Administrator committed
266 267
      })
      item.角色关键词 = role_kws;
268
    }
周成波's avatar
周成波 committed
269 270 271 272 273 274 275 276 277
  } catch (error) {
    ElMessage({
      message: String(error),
      type: "error",
    });
  }
};

const onDrawOne = async (item: any) => {
278
  if (!item.场景描述 && !item.场景关键词) {
周成波's avatar
周成波 committed
279
    ElMessage({
280
      message: "场景描述和场景关键词不能都为空",
周成波's avatar
周成波 committed
281 282 283 284 285 286 287 288 289 290
      type: "error",
    });
    return;
  }
  // 翻译+画图
  if (!form.task_id) {
    form.task_id = utils.genDateTimeStr();
    console.log(form.task_id)
  }
  try {
周成波's avatar
周成波 committed
291
    item.本镜配图 = "src/assets/loading.gif";
292 293 294 295 296
    let temp_prompt = ""
    if (item.场景描述) {temp_prompt = temp_prompt + `Scene description is: ${item.场景描述}\n`};
    if (item.场景关键词) {temp_prompt = temp_prompt + `Scene keywords are: ${item.场景关键词}\n`};
    if (item.角色) {temp_prompt = temp_prompt + `Characters in the scene are: ${item.角色}\n`};
    if (item.角色关键词) {temp_prompt = temp_prompt + `Character keywords are: ${item.角色关键词}\n`};
周成波's avatar
周成波 committed
297
    const sd_describe = await text2videoService.submitLLM(
298
      `${temp_prompt}
周成波's avatar
周成波 committed
299
      Instructions:
Administrator's avatar
Administrator committed
300
      Please understand the above content and return an English description.`, fanyi_llm
周成波's avatar
周成波 committed
301 302 303 304 305 306 307 308 309 310 311
    );
    item.画面描述词 = sd_describe;
    const sd_prompt = item.画面描述词 + "," + sd_prompt_prefix;
    let width = "960";
    let height = "540";
    if (form.screen == "竖屏") {
      width = "540";
      height = "960";
    }
    // console.log(sd_prompt);
    // console.log(sd_negative_prompt_prefix);
Administrator's avatar
Administrator committed
312 313 314 315 316
    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
317 318 319 320 321 322 323
    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
324
    item.本镜配图 = ""
周成波's avatar
周成波 committed
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
  }
};

const onGenVideo = () => {
  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;
  console.log(form.adapt_result_json);
  const video_param_detail = form.adapt_result_json.map(item => {
    return {
      idx: item.编号,
      text: item.场景描述,
      img_path: item.local_image_path
    };
  });
355 356 357 358
  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
359 360 361 362 363
  const video_param = {
    task_id: form.task_id,
    if_need_subtitle: form.if_need_subtitle,
    lang: 'en',
    task_info: video_param_detail,
364 365 366 367
    rate: para_rate,
    volume: para_volume,
    voice: voice.value,
    bgm: bgm.value,
368
    bgm_volume: bgm_volume.value,
周成波's avatar
周成波 committed
369 370 371
    sub_font_size: String(sub_font_size.value),
    sub_font_color: sub_font_color.value,
    sub_position: String(1 - sub_position.value),
周成波's avatar
周成波 committed
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
  }
  text2videoService
    .submitGenVideo(video_param)
    .then((result: string) => {
      console.log(result);
      form.final_video = "";
      form.final_video = result+"?v="+utils.genDateTimeStr();
    })
    .catch((error: any) => {
      // console.error(error);
      ElMessage({
        message: error,
        type: "error",
      });
    });
};

const clean_demo = () => {
  form.chatgpt_prompt = "";
  form.chatgpt_answer = "";
  form.chatgpt_answer_roles = <Wm.RolesItem[]>[];
  form.adapt_result_json = <Wm.ScriptsItem[]>[];
  form.task_id = "";
  form.final_video = "";
}

398 399 400 401
const clean_roles = () => {
  form.chatgpt_answer_roles = <Wm.RolesItem[]>[];
}

周成波's avatar
周成波 committed
402 403 404 405 406 407 408 409 410 411 412 413 414 415
const onChangeScreen = (val: string) => {
  if (debug.value == true) {
    if (val == "竖屏") {
      form.task_id = default_data.en_vertical_data.task_id;
      form.chatgpt_prompt = default_data.en_vertical_data.chatgpt_prompt;
      form.chatgpt_answer = default_data.en_vertical_data.chatgpt_answer;
      form.chatgpt_answer_roles = default_data.en_vertical_data.chatgpt_answer_roles;
      form.adapt_result_json = default_data.en_vertical_data.adapt_result_json;
      form.final_video = default_data.en_vertical_data.final_video;
    }
  }
}

const showsdprompt = (item: any) => {
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
  // 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
434
    form.adapt_result_json[id].local_image_path = val.data[0].path;
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452
    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()
周成波's avatar
周成波 committed
453
}
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475

const onPwdCheckDialog = () => {
  text2videoService
    .submitPwdCheck(pwdCheckValue.value)
    .then((result: string) => {
      if (result == "success") {
        pwdCheckDialogVisible.value = false;
      } else {
        ElMessage({
          message: result,
          type: "error",
        });
      }
    })
    .catch((error: any) => {
      ElMessage({
        message: error,
        type: "error",
      });
    });

}
周成波's avatar
周成波 committed
476 477 478 479 480 481 482 483 484 485
</script>

<template>
  <main class="home-container">
    <!-- 标题 -->
    <el-divider content-position="left">text2video</el-divider>
    <el-form :model="form" label-width="114px" v-loading="loading">
      <el-form-item>
        <div>
          <el-radio-group v-model="form.screen" @change="onChangeScreen">
486
            <el-radio label="横屏" size="large" border/>
周成波's avatar
周成波 committed
487 488 489 490 491
            <el-radio label="竖屏" size="large" border/>
          </el-radio-group>
        </div>
      </el-form-item>
      <el-form-item>
492
        <el-button type="success" @click="clean_demo">清除所有数据</el-button>
周成波's avatar
周成波 committed
493 494
      </el-form-item>
      <!-- Prompt到文案 -->
495
      <el-form-item label="Prompt">
周成波's avatar
周成波 committed
496 497 498
        <el-input v-model="form.chatgpt_prompt" :autosize="true" type="textarea" />
      </el-form-item>
      <el-form-item>
Administrator's avatar
Administrator committed
499
        <el-button type="primary" @click="onSubmitGpt">生成文案({{wenan_llm_name}}</el-button>
500
      </el-form-item>
周成波's avatar
周成波 committed
501 502 503 504 505
      <el-form-item label="文案">
        <el-input v-model="form.chatgpt_answer" :autosize="true" type="textarea" />
      </el-form-item>
      <!-- 角色 -->
      <el-form-item>
Administrator's avatar
Administrator committed
506
        <el-button type="primary" @click="onAdaptRoles">推理角色({{role_llm_name}})、推理角色关键词({{role_keywords_llm_name}}</el-button>
507
        <el-button plain @click="clean_roles">清空总角色列表</el-button>
周成波's avatar
周成波 committed
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524
      </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>
      <!-- 分镜 -->
      <el-form-item>
Administrator's avatar
Administrator committed
525
        <el-button type="primary" @click="onAdapt">分镜、推理场景关键词({{tuili_llm_name}})、英文描述({{fanyi_llm_name}})、绘图</el-button>
周成波's avatar
周成波 committed
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
      </el-form-item>
      <el-form-item label="分镜">
        <el-table :data="form.adapt_result_json" border style="width: 100%; z-index: calc(var(--el-table-index) -1)">
          <el-table-column prop="编号" label="编号" width="60" />
          <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-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-column prop="本镜配图" label="本镜配图" width="300">
            <template v-slot="scope">
              <div>
                <el-image :src="scope.row.本镜配图" :zoom-rate="1.2" :max-scale="1.5" :min-scale="0.5"
                  :preview-src-list="[scope.row.本镜配图]" fit="cover" :hide-on-click-modal="true"
                />
              </div>
            </template>
          </el-table-column>
          <el-table-column width="120" label="操作" align="center">
            <!-- 
            <template v-slot:header>
              <el-button type="danger" size="default" @click="">批量绘制所有图片</el-button>
            </template> 
            -->
            <template v-slot="scope">
Administrator's avatar
Administrator committed
566 567
              <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>
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
              <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
593 594 595 596 597
            </template>
          </el-table-column>
        </el-table>
      </el-form-item>
      <!-- 生成视频 -->
598
      <el-form-item label="设置">
599
        <span style="margin: 0 20px">TTS语速:</span>
600 601 602
        <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>
603
        <span style="margin: 0 20px">TTS音量:</span>
604 605 606
        <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>
607
        <span style="margin: 20px 20px 0 20px">TTS语音:</span>
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
        <el-select v-model="voice" placeholder="Select" style="width: 400px; margin-top: 20px;">
          <el-option
            v-for="item in default_data.voices_en"
            :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>
628
        <span style="margin: 0 20px">背景音乐:</span>
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647
        <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>
648 649
      <el-form-item>
        <span style="margin: 0 20px">背景音量:</span>
周成波's avatar
周成波 committed
650
        <el-slider v-model="bgm_volume" show-input :step="0.1" :min="0" :max="2" :marks="default_data.bgm_volume_marks" style="width: 600px" />
651
      </el-form-item>
652
      <el-form-item>
周成波's avatar
周成波 committed
653
        <span style="margin: 20px 20px">字幕:</span>
654
        <el-switch v-model="form.if_need_subtitle" active-value="true" inactive-value="false"/>
周成波's avatar
周成波 committed
655 656 657 658 659 660
        <div v-if="JSON.parse(form.if_need_subtitle.toLowerCase())">
          <span style="margin-left:30px;">字体颜色:</span>
          <el-color-picker v-model="sub_font_color"/>
          <span style="margin-left:30px;">字体大小:</span>
          <el-input-number v-model="sub_font_size" :min="1" :max="50" controls-position="right" />
          <span style="margin-left:30px;">在屏幕上的位置:</span>
周成波's avatar
周成波 committed
661
          <el-slider v-model="sub_position" :step="0.1" :min="0" :max="1" show-input vertical height="100px" />
周成波's avatar
周成波 committed
662
        </div>
663
      </el-form-item>
周成波's avatar
周成波 committed
664 665 666 667 668 669 670
      <el-form-item>
        <el-button type="primary" @click="onGenVideo">生成视频</el-button>
      </el-form-item>
      <el-form-item>
        <video :src="form.final_video" controls></video>
      </el-form-item>
    </el-form>
671 672 673 674 675 676 677 678 679 680 681
    <!-- 授权密码框 -->
    <el-dialog
      v-model=pwdCheckDialogVisible
      title="请输入密码"
      width="20%"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :show-close="false"
    >
      <el-form :model="form">
        <el-form-item label="密码">
周成波's avatar
周成波 committed
682
          <el-input v-model="pwdCheckValue" autocomplete="off" type="password" show-password @keyup.enter="onPwdCheckDialog()" />
683 684 685 686 687 688 689 690
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="onPwdCheckDialog()">ok</el-button>
        </div>
      </template>
    </el-dialog>
周成波's avatar
周成波 committed
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
  </main>
</template>

<style lang="scss" scoped>
.home-container {
  width: 100%;
}
</style>

<style lang="scss">
.home-container {
  .el-table .el-table__cell {
    z-index: calc(var(--el-table-index) -1);
  }
}
</style>