|
@@ -33,30 +33,50 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="mp3_list" label="读音" width="200">
|
|
|
<template slot-scope="scope">
|
|
|
- <div v-if="scope.row.mp3_list">
|
|
|
- <SoundRecord :wav-blob.sync="scope.row.mp3_list" />
|
|
|
- </div>
|
|
|
+ <template v-if="data.lrc_arr.length > 0 && data.lrc_arr[scope.$index]">
|
|
|
+ <span class="adult-book-lable">字幕时间:</span>
|
|
|
+ <div style="display: flex; align-items: center">
|
|
|
+ <el-input
|
|
|
+ class="adult-book-input"
|
|
|
+ style="width: 200px"
|
|
|
+ v-model.trim="data.lrc_arr[scope.$index].bg"
|
|
|
+ maxlength="200"
|
|
|
+ ></el-input>
|
|
|
+ ~
|
|
|
+ <el-input
|
|
|
+ class="adult-book-input"
|
|
|
+ style="width: 200px"
|
|
|
+ v-model.trim="data.lrc_arr[scope.$index].ed"
|
|
|
+ maxlength="200"
|
|
|
+ ></el-input>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
<template v-else>
|
|
|
- <div :class="['upload-audio-play']">
|
|
|
- <UploadAudio
|
|
|
- v-if="data.property.audio_generation_method === 'upload'"
|
|
|
- :file-id="scope.row.mp3_list"
|
|
|
- :item-index="scope.$index"
|
|
|
- :show-upload="!scope.row.mp3_list"
|
|
|
- @upload="uploads"
|
|
|
- @deleteFile="deleteFiles"
|
|
|
- />
|
|
|
- <div
|
|
|
- v-else-if="data.property.audio_generation_method === 'auto'"
|
|
|
- class="auto-matic"
|
|
|
- @click="handleMatic(scope.$index)"
|
|
|
- >
|
|
|
- <SvgIcon icon-class="voiceprint-line" class="record" />
|
|
|
- <span class="auto-btn">{{ scope.row.mp3_list ? '已生成' : '生成音频' }}</span
|
|
|
- >{{ scope.row.mp3_list ? '成功' : '' }}
|
|
|
- </div>
|
|
|
- <SoundRecord v-else :wav-blob.sync="scope.row.mp3_list" />
|
|
|
+ <div v-if="scope.row.mp3_list">
|
|
|
+ <SoundRecord :wav-blob.sync="scope.row.mp3_list" />
|
|
|
</div>
|
|
|
+ <template v-else>
|
|
|
+ <div :class="['upload-audio-play']">
|
|
|
+ <UploadAudio
|
|
|
+ v-if="data.property.audio_generation_method === 'upload'"
|
|
|
+ :file-id="scope.row.mp3_list"
|
|
|
+ :item-index="scope.$index"
|
|
|
+ :show-upload="!scope.row.mp3_list"
|
|
|
+ @upload="uploads"
|
|
|
+ @deleteFile="deleteFiles"
|
|
|
+ />
|
|
|
+ <div
|
|
|
+ v-else-if="data.property.audio_generation_method === 'auto'"
|
|
|
+ class="auto-matic"
|
|
|
+ @click="handleMatic(scope.$index)"
|
|
|
+ >
|
|
|
+ <SvgIcon icon-class="voiceprint-line" class="record" />
|
|
|
+ <span class="auto-btn">{{ scope.row.mp3_list ? '已生成' : '生成音频' }}</span
|
|
|
+ >{{ scope.row.mp3_list ? '成功' : '' }}
|
|
|
+ </div>
|
|
|
+ <SoundRecord v-else :wav-blob.sync="scope.row.mp3_list" />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
</template>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -153,6 +173,22 @@
|
|
|
</div>
|
|
|
<SvgIcon icon-class="delete-black" size="12" @click="removeFile('lrc')" />
|
|
|
</div>
|
|
|
+ <div class="lrc-box" style="margin: 5px 0">
|
|
|
+ <div v-if="data.lrc_arr && data.lrc_arr.length > 0" class="lrc-box">
|
|
|
+ <span>已有字幕时间节点</span>
|
|
|
+ <el-button type="text" @click="againWordTime">重新生成</el-button>
|
|
|
+ </div>
|
|
|
+ <template v-else>
|
|
|
+ <el-button v-if="!isWordTime" size="medium" @click="createWordTime" :loading="loading"
|
|
|
+ >自动生成字幕节点</el-button
|
|
|
+ >
|
|
|
+ <p v-else>字幕节点生成中...请等待</p>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <div class="adult-book-input-item">
|
|
|
+ <span class="adult-book-lable"></span>
|
|
|
+ <el-button type="primary" size="small" class="distribution" @click="parseLrcFile"> 分配时间 </el-button>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
</ModuleBase>
|
|
|
</template>
|
|
@@ -168,6 +204,7 @@ import SelectUpload from '@/views/book/courseware/create/components/common/Selec
|
|
|
import { GetStaticResources } from '@/api/app';
|
|
|
import cnchar from 'cnchar';
|
|
|
import { ChapterGetBookChapterStruct } from '@/api/book';
|
|
|
+import { segSentences, BatchSegContent, getWordTime, prepareTranscribe, fileToBase64Text } from '@/api/article';
|
|
|
export default {
|
|
|
name: 'NewWordPage',
|
|
|
components: {
|
|
@@ -181,6 +218,8 @@ export default {
|
|
|
return {
|
|
|
data: getNewWordData(),
|
|
|
node_list: [],
|
|
|
+ isWordTime: false,
|
|
|
+ loading: false,
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -235,8 +274,48 @@ export default {
|
|
|
file_id,
|
|
|
};
|
|
|
this.data.file_id_list.push(file_id);
|
|
|
+ let _this = this;
|
|
|
+ _this.loading = true;
|
|
|
+ let data = {
|
|
|
+ file_id: file_id,
|
|
|
+ };
|
|
|
+ fileToBase64Text(data)
|
|
|
+ .then((res) => {
|
|
|
+ let taskIddata = {
|
|
|
+ fileName: name,
|
|
|
+ speechBase64: res.base64_text,
|
|
|
+ language: 'ch',
|
|
|
+ };
|
|
|
+ prepareTranscribe(taskIddata)
|
|
|
+ .then((reses) => {
|
|
|
+ _this.loading = false;
|
|
|
+ _this.$set(_this.data, 'taskId', reses.data.taskId);
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ _this.loading = false;
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ _this.loading = false;
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
+ getBase64(file) {
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ let reader = new FileReader();
|
|
|
+ let imgResult = '';
|
|
|
+ reader.readAsDataURL(file);
|
|
|
+ reader.onload = function () {
|
|
|
+ imgResult = reader.result;
|
|
|
+ };
|
|
|
+ reader.onerror = function (error) {
|
|
|
+ reject(error);
|
|
|
+ };
|
|
|
+ reader.onloadend = function () {
|
|
|
+ resolve(imgResult);
|
|
|
+ };
|
|
|
+ });
|
|
|
+ },
|
|
|
/**
|
|
|
* 删除文件
|
|
|
* @param {'audio' | 'lrc'} type
|
|
@@ -408,6 +487,39 @@ export default {
|
|
|
handleChange(val) {
|
|
|
this.data.source_courseware_id = val[val.length - 1];
|
|
|
},
|
|
|
+ createWordTime() {
|
|
|
+ if (this.data.taskId) {
|
|
|
+ let verseList = [];
|
|
|
+ this.data.new_word_list.forEach((sItem, index) => {
|
|
|
+ // item.forEach((sItem, sIndex) => {
|
|
|
+ verseList.push(sItem.new_word);
|
|
|
+ // });
|
|
|
+ });
|
|
|
+ if (verseList.length > 0) {
|
|
|
+ this.isWordTime = true;
|
|
|
+ let data = {
|
|
|
+ taskId: this.data.taskId,
|
|
|
+ verseList: JSON.stringify(verseList),
|
|
|
+ matchType: 'chinese',
|
|
|
+ language: 'ch',
|
|
|
+ };
|
|
|
+ getWordTime(data)
|
|
|
+ .then((res) => {
|
|
|
+ this.data.lrc_arr = res.data.result;
|
|
|
+ this.isWordTime = false;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.isWordTime = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.$message.warning('请先上传音频');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ againWordTime() {
|
|
|
+ this.isWordTime = false;
|
|
|
+ this.$set(this.data, 'lrc_arr', []);
|
|
|
+ },
|
|
|
},
|
|
|
created() {
|
|
|
this.getBookChapterStructExpandList();
|