فهرست منبع

语音矩阵兼容最后一个lrc结束时间为-1

dusenyao 3 سال پیش
والد
کامیت
83cb398054
1فایلهای تغییر یافته به همراه45 افزوده شده و 17 حذف شده
  1. 45 17
      src/components/Adult/preview/VoiceMatrix.vue

+ 45 - 17
src/components/Adult/preview/VoiceMatrix.vue

@@ -331,6 +331,11 @@ export default {
       if (mp3_list === undefined) return "";
       return "source" in mp3_list ? mp3_list.source : "";
     },
+    mp3Duration() {
+      let mp3_list = this.curQue.mp3_list[0];
+      if (mp3_list === undefined) return 0;
+      return mp3_list.media_duration * 1000;
+    },
     hasSelectedCell() {
       let { type, index } = this.selectedLine;
       let { row, column } = this.selectCell;
@@ -412,12 +417,15 @@ export default {
     },
 
     setRecordingFileName(row, column) {
-      let { type, text, sentence_data, pinyin_english_data } = this.curQue.voiceMatrix.matrix[row][
-        column
-      ];
-      if (type === 'text') this.fileName = text;
-      if (type === 'SentenceSegwordChs') this.fileName = sentence_data.sentence;
-      if (type === 'PinyinEnglish') this.fileName = pinyin_english_data.pinyin;
+      let {
+        type,
+        text,
+        sentence_data,
+        pinyin_english_data
+      } = this.curQue.voiceMatrix.matrix[row][column];
+      if (type === "text") this.fileName = text;
+      if (type === "SentenceSegwordChs") this.fileName = sentence_data.sentence;
+      if (type === "PinyinEnglish") this.fileName = pinyin_english_data.pinyin;
     },
 
     checkboxMouseenter(isSelected, type) {
@@ -457,26 +465,46 @@ export default {
       this.lrcArray = [];
       let { type, index } = this.selectedLine;
       if (type.length > 0 && index >= 0 && type === "row") {
-        this.curQue.voiceMatrix.matrix[index].forEach(item => {
-          if (
-            item.type === "SentenceSegwordChs" || item.type === 'PinyinEnglish' ||
-            (item.type === "text" && item.text.length > 0)
-          ) {
-            this.lrcArray.push(item.lrc_data);
+        this.curQue.voiceMatrix.matrix[index].forEach(
+          ({ type, text, lrc_data }) => {
+            if (
+              type === "SentenceSegwordChs" ||
+              type === "PinyinEnglish" ||
+              (type === "text" && text.length > 0)
+            ) {
+              if (lrc_data.end_time === -1) {
+                this.lrcArray.push({
+                  begin_time: lrc_data.begin_time,
+                  end_time: this.mp3Duration,
+                  text: lrc_data.text
+                });
+                return;
+              }
+              this.lrcArray.push(lrc_data);
+            }
           }
-        });
+        );
         if (this.lrcArray.length > 0) this.lrcPlay(this.lrcArray[0], 0);
         return;
       }
 
       if (type.length > 0 && index >= 0 && type === "column") {
         this.curQue.voiceMatrix.matrix.forEach(item => {
-          let data = item[index];
+          let { type, text, lrc_data } = item[index];
           if (
-            data.type === "SentenceSegwordChs" || data.type === 'PinyinEnglish' ||
-            (data.type === "text" && data.text.length > 0)
+            type === "SentenceSegwordChs" ||
+            type === "PinyinEnglish" ||
+            (type === "text" && text.length > 0)
           ) {
-            this.lrcArray.push(data.lrc_data);
+            if (lrc_data.end_time === -1) {
+              this.lrcArray.push({
+                begin_time: lrc_data.begin_time,
+                end_time: this.mp3Duration,
+                text: lrc_data.text
+              });
+              return;
+            }
+            this.lrcArray.push(lrc_data);
           }
         });
         if (this.lrcArray.length > 0) this.lrcPlay(this.lrcArray[0], 0);