Pārlūkot izejas kodu

Merge branch 'master' of http://gcls-git.helxsoft.cn/GCLS/eep_page

zq 4 dienas atpakaļ
vecāks
revīzija
1d112eb3e8

+ 6 - 1
src/views/book/courseware/create/components/question/character/Character.vue

@@ -22,6 +22,8 @@
               @blur="handleMindMap"
             />
             <el-button @click="identify(item, index)">识别</el-button>
+            <SoundRecord v-if="item.audio_file_id" :wav-blob.sync="item.audio_file_id" />
+            <el-button v-else @click="handleMatic(item.content, index)">生成音频</el-button>
             <el-button @click="handleDelete(index)">删除此条</el-button>
           </div>
           <div class="option-item">
@@ -97,10 +99,11 @@ import { getCharacterData, modelList, getOption } from '@/views/book/courseware/
 import { GetStaticResources, TextToAudioFile } from '@/api/app';
 import cnchar from 'cnchar';
 import UploadFile from '../../base/common/UploadFile.vue';
+import SoundRecord from '@/views/book/courseware/create/components/question/fill/components/SoundRecord.vue';
 
 export default {
   name: 'CharacterPage',
-  components: { UploadFile },
+  components: { UploadFile, SoundRecord },
   mixins: [ModuleMixin],
   data() {
     return {
@@ -162,6 +165,8 @@ export default {
     handleMatic(con, index) {
       TextToAudioFile({
         text: con.replace(/<[^>]+>/g, ''),
+        voice_type: this.data.property.voice_type,
+        emotion: this.data.property.emotion,
       })
         .then(({ status, file_id, file_url }) => {
           if (status === 1) {

+ 36 - 1
src/views/book/courseware/create/components/question/character/CharacterSetting.vue

@@ -63,6 +63,23 @@
           </el-radio>
         </el-radio-group>
       </el-form-item>
+      <template v-if="property.is_enable_voice === 'true'">
+        <el-form-item label="音色">
+          <el-select v-model="property.voice_type" placeholder="请选择">
+            <el-option
+              v-for="{ voice_type, name } in voice_type_list"
+              :key="voice_type"
+              :label="name"
+              :value="voice_type"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="风格情感">
+          <el-select v-model="property.emotion">
+            <el-option v-for="{ emotion, name } in emotion_list" :key="emotion" :label="name" :value="emotion" />
+          </el-select>
+        </el-form-item>
+      </template>
     </el-form>
   </div>
 </template>
@@ -78,6 +95,7 @@ import {
   isEnable,
   frameList,
 } from '@/views/book/courseware/data/character';
+import { GetTextToAudioConfParamList } from '@/api/app';
 
 export default {
   name: 'CharacterSetting',
@@ -90,9 +108,26 @@ export default {
       funList,
       showList,
       frameList,
+      voice_type_list: [],
+      emotion_list: [],
     };
   },
-  methods: {},
+  methods: {
+    // 得到文本转音频的配置参数列表
+    getTextToAudioConfParamList() {
+      GetTextToAudioConfParamList()
+        .then(({ status, voice_type_list, emotion_list }) => {
+          if (status === 1) {
+            this.voice_type_list = voice_type_list;
+            this.emotion_list = emotion_list;
+          }
+        })
+        .catch(() => {});
+    },
+  },
+  created() {
+    this.getTextToAudioConfParamList();
+  },
 };
 </script>
 

+ 7 - 1
src/views/book/courseware/create/components/question/fill/components/SoundRecord.vue

@@ -60,7 +60,13 @@ export default {
     wavBlob: {
       handler(val) {
         if (!val) return;
-        GetFileStoreInfo({ file_id: val }).then(({ file_url, media_duration }) => {
+        let obj = {};
+        if (typeof val === 'string') {
+          obj = { file_id: val };
+        } else if (typeof val === 'object') {
+          obj = { file_id: val.file_id };
+        }
+        GetFileStoreInfo(obj).then(({ file_url, media_duration }) => {
           this.file_url = file_url;
           this.recordTime = media_duration;
           this.recordTimes = JSON.parse(JSON.parse(media_duration));

+ 3 - 1
src/views/book/courseware/data/article.js

@@ -77,7 +77,9 @@ export function getArticleProperty() {
     is_first_sentence_first_hz_pinyin_first_char_upper_case: 'true', // 句首大写
 
     multilingual_position: multilingualList[1].value,
-    content_height:'', // 内容高度
+    content_height: '', // 内容高度
+    voice_type: '', // 音色
+    emotion: '', // 风格,情感
   };
 }
 

+ 2 - 0
src/views/book/courseware/data/character.js

@@ -85,6 +85,8 @@ export function getCharacterProperty() {
     write_number: 5,
     is_enable_play_back: showList[0].value,
     is_enable_error: showList[0].value,
+    voice_type: '', // 音色
+    emotion: '', // 风格,情感
   };
 }
 

+ 3 - 1
src/views/book/courseware/data/dialogueArticle.js

@@ -117,7 +117,9 @@ export function getArticleProperty() {
     role_list: [getRole(0), getRole(1)],
 
     multilingual_position: multilingualList[0].value,
-    content_height:'', // 内容高度
+    content_height: '', // 内容高度
+    voice_type: '', // 音色
+    emotion: '', // 风格,情感
   };
 }