guanchunjie před 3 roky
rodič
revize
9a2c9a9bb1

+ 164 - 0
src/components/Adult/inputModules/ Engineaudio.vue

@@ -0,0 +1,164 @@
+<!--  -->
+<template>
+  <div class="">
+    <template v-if="curQue.mp3_list && curQue.mp3_list.length > 0">
+      <div class="create_mp3_list">
+        <span>引擎音频:</span>
+        <span class="mp3_file_name">{{ curQue.mp3_list[0].name }}</span>
+        <img
+          src="../../../../assets/adult/del-close.png"
+          class="mp3_del"
+          @click="delMp3"
+        />
+      </div>
+    </template>
+    <template v-else>
+      <el-button :loading="CreadMp3loading" size="small" @click="CreadMp3"
+        >生成音频</el-button
+      >
+    </template>
+
+    <el-button size="medium" @click="createWordTime"
+      >自动生成字幕节点</el-button
+    >
+  </div>
+</template>
+
+<script>
+import {
+  prepareTranscribe,
+  getWordTime,
+  compareSenTenceTime,
+  textCreadMp3,
+  getContentFile,
+} from "@/api/ajax";
+const Base64 = require("js-base64").Base64;
+export default {
+  components: {},
+  props: ["curQue"],
+  data() {
+    return {};
+  },
+  computed: {},
+  watch: {},
+  //方法集合
+  methods: {
+    // 根据文章生成MP3
+    CreadMp3() {
+      let _this = this;
+      if (_this.curQue.mp3_list.length > 0) {
+        _this.$message.warning("已有音频,请勿重复生成");
+        return;
+      }
+      if (!_this.curQue.article) {
+        _this.$message.warning("请先输入内容,在生成音频");
+        return;
+      }
+      _this.CreadMp3loading = true;
+      textCreadMp3({
+        text: _this.curQue.article,
+      }).then((res) => {
+        res.data.fileInfo.id = "[FID##" + res.data.fileInfo.file_id + "##FID]";
+        res.data.fileInfo.name = res.data.fileInfo.file_name;
+        let fileList = [res.data.fileInfo];
+        console.log(fileList);
+        _this.$set(_this.curQue, "mp3_list", fileList);
+        _this.CreadMp3loading = false;
+        _this.$message.success("生成成功");
+      });
+    },
+    //删除生成的mp3
+    delMp3() {
+      this.curQue.mp3_list.splice(0, 1);
+    },
+    // 得到文件流
+    getfillLiu() {
+      this.loading = true;
+      let _this = this;
+      return new Promise(function (resolve, reject) {
+        if (
+          _this.curQue.mp3_list &&
+          _this.curQue.mp3_list.length > 0 &&
+          _this.curQue.mp3_list[0].id
+        ) {
+          let Mname = "file_store_manager-GetFileByteBase64Text";
+          let id = _this.curQue.mp3_list[0].id
+            .replace("[FID##", "")
+            .replace("##FID]", "");
+          let data = {
+            file_id: id,
+          };
+          getContentFile(Mname, data).then((res) => {
+            let taskIddata = {
+              fileName: _this.curQue.mp3_list[0].name,
+              speechBase64: res.base64_text,
+              language: "ch",
+            };
+            prepareTranscribe(taskIddata).then((res) => {
+              _this.$set(_this.curQue, "taskId", res.data.taskId);
+              _this.loading = false;
+              resolve();
+            });
+          });
+        } else {
+          _this.$message.warning("请先上传音频");
+        }
+      });
+    },
+    createWordTime() {
+      this.getfillLiu().then(() => {
+        if (this.curQue.taskId) {
+          let verseList = [];
+          this.curQue.detail.forEach((item) => {
+            verseList = verseList.concat(item.sentences);
+          });
+          if (verseList.length > 0) {
+            this.isWordTime = true;
+            let data = {
+              taskId: this.curQue.taskId,
+              verseList: JSON.stringify(verseList),
+              matchType: "chinese",
+              language: "ch",
+            };
+            getWordTime(data).then((res) => {
+              this.curQue.wordTime = res.data.result;
+              this.isWordTime = false;
+            });
+          }
+        } else {
+          this.$message.warning("请先上传音频");
+        }
+      });
+    },
+  },
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {},
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {},
+  beforeCreate() {}, //生命周期 - 创建之前
+  beforeMount() {}, //生命周期 - 挂载之前
+  beforeUpdate() {}, //生命周期 - 更新之前
+  updated() {}, //生命周期 - 更新之后
+  beforeDestroy() {}, //生命周期 - 销毁之前
+  destroyed() {}, //生命周期 - 销毁完成
+  activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
+};
+</script>
+<style lang='scss' scoped>
+//@import url(); 引入公共css类
+.create_mp3_list {
+  display: flex;
+  justify-content: flex-start;
+  align-items: center;
+  > span {
+    font-size: 16px;
+    font-weight: bold;
+    margin-right: 10px;
+  }
+  > img {
+    width: 24px;
+    height: 24px;
+    cursor: pointer;
+  }
+}
+</style>

+ 68 - 30
src/components/Adult/inputModules/ArticleTemChs/index.vue

@@ -71,9 +71,28 @@
         :changeIsPara="changeIsPara"
       />
     </div>
-    <el-button :loading="CreadMp3loading" size="small" @click="CreadMp3"
-      >生成音频</el-button
+    <template
+      v-if="
+        curQue.mp3_list &&
+        curQue.mp3_list.length > 0 &&
+        curQue.mp3_list[0].source
+      "
     >
+      <div class="create_mp3_list">
+        <span>引擎音频:</span>
+        <span class="mp3_file_name">{{ curQue.mp3_list[0].name }}</span>
+        <img
+          src="../../../../assets/adult/del-close.png"
+          class="mp3_del"
+          @click="delMp3"
+        />
+      </div>
+    </template>
+    <template v-else>
+      <el-button :loading="CreadMp3loading" size="small" @click="CreadMp3"
+        >生成音频</el-button
+      >
+    </template>
     <div class="NPC-Book-Paragraph" v-if="isPara">
       <Paragraph :curQue="curQue" :isClause="isClause" :sureSeg="sureSeg" />
     </div>
@@ -235,32 +254,33 @@ export default {
       this.loading = true;
       let _this = this;
       return new Promise(function (resolve, reject) {
-        let id = "";
-        if (_this.curQue.mp3_list[0].id.indexOf("#") != -1) {
-          id = _this.curQue.mp3_list[0].id.substring(
-            6,
-            _this.curQue.mp3_list[0].id.length - 6
-          );
-        } else {
-          id = _this.curQue.mp3_list[0].id;
-        }
-
-        let Mname = "file_store_manager-GetFileByteBase64Text";
-        let data = {
-          file_id: id,
-        };
-        getContentFile(Mname, data).then((res) => {
-          let taskIddata = {
-            fileName: _this.curQue.mp3_list[0].name,
-            speechBase64: res.base64_text,
-            language: "ch",
+        if (
+          _this.curQue.mp3_list &&
+          _this.curQue.mp3_list.length > 0 &&
+          _this.curQue.mp3_list[0].id
+        ) {
+          let Mname = "file_store_manager-GetFileByteBase64Text";
+          let id = _this.curQue.mp3_list[0].id
+            .replace("[FID##", "")
+            .replace("##FID]", "");
+          let data = {
+            file_id: id,
           };
-          prepareTranscribe(taskIddata).then((res) => {
-            _this.$set(_this.curQue, "taskId", res.data.taskId);
-            _this.loading = false;
-            resolve();
+          getContentFile(Mname, data).then((res) => {
+            let taskIddata = {
+              fileName: _this.curQue.mp3_list[0].name,
+              speechBase64: res.base64_text,
+              language: "ch",
+            };
+            prepareTranscribe(taskIddata).then((res) => {
+              _this.$set(_this.curQue, "taskId", res.data.taskId);
+              _this.loading = false;
+              resolve();
+            });
           });
-        });
+        } else {
+          _this.$message.warning("请先上传音频");
+        }
       });
     },
     // 根据文章生成MP3
@@ -278,15 +298,18 @@ export default {
       textCreadMp3({
         text: _this.curQue.article,
       }).then((res) => {
-        res.data.fileInfo.id = res.data.fileInfo.file_id;
+        res.data.fileInfo.id = "[FID##" + res.data.fileInfo.file_id + "##FID]";
         res.data.fileInfo.name = res.data.fileInfo.file_name;
         let fileList = [res.data.fileInfo];
-        //this.$set(this.curQue, "mp3_file_base64", res.data.fileBase64);
         _this.$set(_this.curQue, "mp3_list", fileList);
         _this.CreadMp3loading = false;
         _this.$message.success("生成成功");
       });
     },
+    //删除生成的mp3
+    delMp3() {
+      this.curQue.mp3_list.splice(0, 1);
+    },
     // 保存校对
     saveCompare() {
       if (this.compareType == "文字") {
@@ -329,7 +352,6 @@ export default {
             duration: item.response.file_info_list[0].media_duration,
             url: item.response.file_info_list[0].file_url,
             id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
-
             media_duration: item.response.file_info_list[0].media_duration, //音频时长
           };
           articleImgRes.push(obj);
@@ -542,7 +564,8 @@ export default {
         this.curQue.mp3_list = [];
       }
       this.fileCon.img_list = JSON.parse(JSON.stringify(this.curQue.img_list));
-      this.fileCon.mp3_list = JSON.parse(JSON.stringify(this.curQue.mp3_list));
+      let mp3_list = JSON.parse(JSON.stringify(this.curQue.mp3_list));
+      this.fileCon.mp3_list = mp3_list.filter((item) => item.source !== "tts");
     } else {
       this.initCurQueData();
     }
@@ -558,6 +581,21 @@ export default {
 </script>
 <style lang='scss' scoped>
 //@import url(); 引入公共css类
+.create_mp3_list {
+  display: flex;
+  justify-content: flex-start;
+  align-items: center;
+  > span {
+    font-size: 16px;
+    font-weight: bold;
+    margin-right: 10px;
+  }
+  > img {
+    width: 24px;
+    height: 24px;
+    cursor: pointer;
+  }
+}
 p {
   margin: 0;
   padding: 0;

+ 69 - 30
src/components/Adult/inputModules/DialogueArticleChs/index.vue

@@ -116,9 +116,28 @@
         :changeIsPara="changeIsPara"
       />
     </div>
-    <el-button :loading="CreadMp3loading" size="small" @click="CreadMp3"
-      >生成音频</el-button
+    <template
+      v-if="
+        curQue.mp3_list &&
+        curQue.mp3_list.length > 0 &&
+        curQue.mp3_list[0].source
+      "
     >
+      <div class="create_mp3_list">
+        <span>引擎音频:</span>
+        <span class="mp3_file_name">{{ curQue.mp3_list[0].name }}</span>
+        <img
+          src="../../../../assets/adult/del-close.png"
+          class="mp3_del"
+          @click="delMp3"
+        />
+      </div>
+    </template>
+    <template v-else>
+      <el-button :loading="CreadMp3loading" size="small" @click="CreadMp3"
+        >生成音频</el-button
+      >
+    </template>
     <div class="NPC-Book-Paragraph" v-if="isPara">
       <Paragraph :curQue="curQue" :isClause="isClause" :sureSeg="sureSeg" />
     </div>
@@ -332,32 +351,33 @@ export default {
       this.loading = true;
       let _this = this;
       return new Promise(function (resolve, reject) {
-        let id = "";
-        if (_this.curQue.mp3_list[0].id.indexOf("#") != -1) {
-          id = _this.curQue.mp3_list[0].id.substring(
-            6,
-            _this.curQue.mp3_list[0].id.length - 6
-          );
-        } else {
-          id = _this.curQue.mp3_list[0].id;
-        }
-
-        let Mname = "file_store_manager-GetFileByteBase64Text";
-        let data = {
-          file_id: id,
-        };
-        getContentFile(Mname, data).then((res) => {
-          let taskIddata = {
-            fileName: _this.curQue.mp3_list[0].name,
-            speechBase64: res.base64_text,
-            language: "ch",
+        if (
+          _this.curQue.mp3_list &&
+          _this.curQue.mp3_list.length > 0 &&
+          _this.curQue.mp3_list[0].id
+        ) {
+          let Mname = "file_store_manager-GetFileByteBase64Text";
+          let id = _this.curQue.mp3_list[0].id
+            .replace("[FID##", "")
+            .replace("##FID]", "");
+          let data = {
+            file_id: id,
           };
-          prepareTranscribe(taskIddata).then((res) => {
-            _this.$set(_this.curQue, "taskId", res.data.taskId);
-            _this.loading = false;
-            resolve();
+          getContentFile(Mname, data).then((res) => {
+            let taskIddata = {
+              fileName: _this.curQue.mp3_list[0].name,
+              speechBase64: res.base64_text,
+              language: "ch",
+            };
+            prepareTranscribe(taskIddata).then((res) => {
+              _this.$set(_this.curQue, "taskId", res.data.taskId);
+              _this.loading = false;
+              resolve();
+            });
           });
-        });
+        } else {
+          _this.$message.warning("请先上传音频");
+        }
       });
     },
     // 根据文章生成MP3
@@ -375,15 +395,18 @@ export default {
       textCreadMp3({
         text: _this.curQue.article,
       }).then((res) => {
-        res.data.fileInfo.id = res.data.fileInfo.file_id;
+        res.data.fileInfo.id = "[FID##" + res.data.fileInfo.file_id + "##FID]";
         res.data.fileInfo.name = res.data.fileInfo.file_name;
         let fileList = [res.data.fileInfo];
-        //this.$set(this.curQue, "mp3_file_base64", res.data.fileBase64);
         _this.$set(_this.curQue, "mp3_list", fileList);
         _this.CreadMp3loading = false;
         _this.$message.success("生成成功");
       });
     },
+    //删除生成的mp3
+    delMp3() {
+      this.curQue.mp3_list.splice(0, 1);
+    },
     // 保存校对
     saveCompare() {
       this.compareloading = true;
@@ -426,7 +449,6 @@ export default {
             duration: item.response.file_info_list[0].media_duration,
             url: item.response.file_info_list[0].file_url,
             id: "[FID##" + item.response.file_info_list[0].file_id + "##FID]",
-
             media_duration: item.response.file_info_list[0].media_duration, //音频时长
           };
           articleImgRes.push(obj);
@@ -590,6 +612,7 @@ export default {
           this.curQue.detail.forEach((item) => {
             verseList = verseList.concat(item.sentences);
           });
+          console.log(verseList);
           if (verseList.length > 0) {
             this.isWordTime = true;
             let data = {
@@ -683,7 +706,8 @@ export default {
         this.curQue.mp3_list = [];
       }
       this.fileCon.img_list = JSON.parse(JSON.stringify(this.curQue.img_list));
-      this.fileCon.mp3_list = JSON.parse(JSON.stringify(this.curQue.mp3_list));
+      let mp3_list = JSON.parse(JSON.stringify(this.curQue.mp3_list));
+      this.fileCon.mp3_list = mp3_list.filter((item) => item.source !== "tts");
     } else {
       this.initCurQueData();
     }
@@ -699,6 +723,21 @@ export default {
 </script>
 <style lang='scss' scoped>
 //@import url(); 引入公共css类
+.create_mp3_list {
+  display: flex;
+  justify-content: flex-start;
+  align-items: center;
+  > span {
+    font-size: 16px;
+    font-weight: bold;
+    margin-right: 10px;
+  }
+  > img {
+    width: 24px;
+    height: 24px;
+    cursor: pointer;
+  }
+}
 p {
   margin: 0;
   padding: 0;

+ 1 - 0
src/components/Adult/preview/ArticleViewChs/NormalModelChs.vue

@@ -12,6 +12,7 @@
         :mp3="curQue.mp3_list[0].id"
         :getCurTime="getCurTime"
         :duration="curQue.mp3_list[0].media_duration"
+        :mp3Source="curQue.mp3_list[0].source"
         ref="audioLine"
       />
     </div>

+ 2 - 1
src/components/Adult/preview/ArticleViewChs/PhraseModelChs.vue

@@ -9,8 +9,9 @@
     >
       <AudioLine
         audioId="artPhraseAudio"
-        :mp3="curQue.mp3_list[0].url"
+        :mp3="curQue.mp3_list[0].id"
         :getCurTime="getCurTime"
+        :mp3Source="curQue.mp3_list[0].source"
         ref="audioLine"
       />
     </div>

+ 3 - 4
src/components/Adult/preview/ArticleViewChs/Practicechs.vue

@@ -5,18 +5,17 @@
       <div
         class="aduioLine-content"
         v-if="
-          curQue.mp3_list &&
-          curQue.mp3_list.length > 0 &&
-          curQue.mp3_list[0].url
+          curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].id
         "
       >
         <AudioLine
           audioId="artPraAudio"
-          :mp3="curQue.mp3_list[0].url"
+          :mp3="curQue.mp3_list[0].id"
           :getCurTime="getCurTime"
           ref="audioLine"
           :stopAudio="stopAudio"
           :width="555"
+          :mp3Source="curQue.mp3_list[0].source"
           @handleChangeStopAudio="handleChangeStopAudio"
         />
       </div>

+ 2 - 1
src/components/Adult/preview/ArticleViewChs/WordModelChs.vue

@@ -9,8 +9,9 @@
     >
       <AudioLine
         audioId="artWordAudio"
-        :mp3="curQue.mp3_list[0].url"
+        :mp3="curQue.mp3_list[0].id"
         :getCurTime="getCurTime"
+        :mp3Source="curQue.mp3_list[0].source"
         ref="audioLine"
       />
     </div>

+ 1 - 0
src/components/Adult/preview/DialogueArticleViewChs/NormalModelChs.vue

@@ -11,6 +11,7 @@
         audioId="diaNormalAudio"
         :mp3="curQue.mp3_list[0].id"
         :getCurTime="getCurTime"
+        :mp3Source="curQue.mp3_list[0].source"
         ref="audioLine"
       />
     </div>

+ 4 - 3
src/components/Adult/preview/DialogueArticleViewChs/PhraseModelChs.vue

@@ -4,13 +4,14 @@
     <div
       class="aduioLine-box"
       v-if="
-        curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].url
+        curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].id
       "
     >
       <AudioLine
         audioId="diaPhraAudio"
-        :mp3="curQue.mp3_list[0].url"
+        :mp3="curQue.mp3_list[0].id"
         :getCurTime="getCurTime"
+        :mp3Source="curQue.mp3_list[0].source"
         ref="audioLine"
       />
     </div>
@@ -240,7 +241,7 @@ export default {
     "colorBox",
     "themeColor",
     "noFont",
-    "currentTreeID"
+    "currentTreeID",
   ],
   components: {
     AudioLine,

+ 3 - 2
src/components/Adult/preview/DialogueArticleViewChs/Practicechs.vue

@@ -4,18 +4,19 @@
     <div
       class="aduioLine-box aduioLine-practice"
       v-if="
-        curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].url
+        curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].id
       "
     >
       <div class="aduioLine-content">
         <AudioLine
           audioId="diaPraAudio"
-          :mp3="curQue.mp3_list[0].url"
+          :mp3="curQue.mp3_list[0].id"
           :getCurTime="getCurTime"
           ref="audioLine"
           :stopAudio="stopAudio"
           :width="555"
           :isRepeat="isRepeat"
+          :mp3Source="curQue.mp3_list[0].source"
           @handleChangeStopAudio="handleChangeStopAudio"
         />
       </div>

+ 3 - 2
src/components/Adult/preview/DialogueArticleViewChs/WordModelChs.vue

@@ -4,13 +4,14 @@
     <div
       class="aduioLine-box"
       v-if="
-        curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].url
+        curQue.mp3_list && curQue.mp3_list.length > 0 && curQue.mp3_list[0].id
       "
     >
       <AudioLine
         audioId="diaWordAudio"
-        :mp3="curQue.mp3_list[0].url"
+        :mp3="curQue.mp3_list[0].id"
         :getCurTime="getCurTime"
+        :mp3Source="curQue.mp3_list[0].source"
         ref="audioLine"
       />
     </div>

+ 2 - 2
vue.config.js

@@ -42,8 +42,8 @@ module.exports = {
       // change xxx-api/login => mock/login
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `http://gcls.utschool.cn/`,
-        //target: `http://gcls.helxsoft.cn/`,
+        //target: `http://gcls.utschool.cn/`,
+        target: `http://gcls.helxsoft.cn/`,
         changeOrigin: true,
         pathRewrite: {
           ['^' + process.env.VUE_APP_BASE_API]: ''