Browse Source

语音矩阵增加分析语音文件

dusenyao 3 years ago
parent
commit
e3b2ec2783
1 changed files with 39 additions and 3 deletions
  1. 39 3
      src/components/Adult/inputModules/VoiceMatrix.vue

+ 39 - 3
src/components/Adult/inputModules/VoiceMatrix.vue

@@ -25,6 +25,8 @@
       分配lrc
     </el-button>
 
+    <el-button type="primary" size="small" @click="analyzeVoiceFile">根据语音和文本进行打点标记</el-button>
+
     <div class="voice-matrix-input">
       <el-input
         v-model="rowNumber"
@@ -206,6 +208,38 @@ export default {
       return matrix;
     },
 
+    analyzeVoiceFile() {
+      let mp3_list = this.curQue.mp3_list;
+      if (mp3_list.length === 0) {
+        return this.$message.warning("请先上传mp3文件");
+      }
+      let text_list = [];
+      this.curQue.voiceMatrix.matrix.forEach(row => {
+        row.forEach(({ type, text, sentence_data }, i) => {
+          if (type === "connection" || (type === "text" && text.length === 0)) {
+            row[i].lrc_data = {};
+            return;
+          }
+          if (type === 'text') {
+            text_list.push(text);
+            return;
+          }
+          if (type === 'SentenceSegwordChs') {
+            text_list.push(sentence_data.sentence);
+          }
+        });
+      });
+      let loading = this.$loading({ text: '正在分析,请等待' });
+      getContentFile("tool-AnalyzeVoiceFile", {
+        file_id: mp3_list[0].file_id,
+        text_list
+      }).then(({ lrc_list }) => {
+        loading.close();
+        this.curQue.lrc_arr = lrc_list;
+        this.distribution();
+      });
+    },
+
     parseFile(file_id) {
       getContentFile("tool-ParseLRCFile", {
         content_type: "FILE",
@@ -217,7 +251,8 @@ export default {
 
     distribution() {
       let lrcList = this.curQue.lrc_list;
-      if (lrcList.length === 0) {
+      let lrcArr = this.curQue.lrc_arr;
+      if (lrcList.length === 0 && lrcArr.length === 0) {
         return this.$message.warning("请先上传lrc文件");
       }
       let curIndex = 0;
@@ -228,7 +263,7 @@ export default {
             return;
           }
 
-          let lrcData = this.curQue.lrc_arr[curIndex];
+          let lrcData = lrcArr[curIndex];
           if (lrcData) {
             row[i].lrc_data = lrcData;
             curIndex += 1;
@@ -246,7 +281,8 @@ export default {
             name,
             media_duration: response.file_info_list[0].media_duration,
             temporary_url: response.file_info_list[0].file_url,
-            url: "[FID##" + response.file_info_list[0].file_id + "##FID]"
+            url: "[FID##" + response.file_info_list[0].file_id + "##FID]",
+            file_id: response.file_info_list[0].file_id
           });
         }
       });