Преглед на файлове

生成音频兼容汉字

natasha преди 1 година
родител
ревизия
0ba5019946

+ 21 - 15
src/views/exercise_questions/create/components/exercises/ChineseQuestion.vue

@@ -249,24 +249,30 @@ export default {
     },
     // 自动生成音频
     handleMatically(item, i) {
-      if (item.pinyin.trim()) {
-        this.loading_list[i].loading = true;
-        let MethodName = 'tool-PinyinToVoiceFile';
-        let data = {
+      let MethodName = 'tool-TextToVoiceFile';
+      let data = {};
+      if (item.content.trim()) {
+        data = {
+          text: item.content.trim(),
+        };
+      } else if (item.pinyin.trim()) {
+        MethodName = 'tool-PinyinToVoiceFile';
+        data = {
           pinyin: item.pinyin.trim().split(' ').join(','),
         };
-        GetStaticResources(MethodName, data)
-          .then((res) => {
-            this.loading_list[i].loading = false;
-            if (res.status === 1) {
-              item.audio_file_id = res.file_id;
-              this.data.file_id_list.push(res.file_id);
-            }
-          })
-          .catch(() => {
-            this.loading_list[i].loading = false;
-          });
       }
+      this.loading_list[i].loading = true;
+      GetStaticResources(MethodName, data)
+        .then((res) => {
+          this.loading_list[i].loading = false;
+          if (res.status === 1) {
+            item.audio_file_id = res.file_id;
+            this.data.file_id_list.push(res.file_id);
+          }
+        })
+        .catch(() => {
+          this.loading_list[i].loading = false;
+        });
     },
     // 生成汉字
     handleChineseStrokes(item, i) {

+ 21 - 15
src/views/exercise_questions/create/components/exercises/WordCardQuestion.vue

@@ -310,24 +310,30 @@ export default {
     },
     // 自动生成音频
     handleMatically(item, i) {
-      if (item.pinyin.trim()) {
-        this.loading_list[i].loading = true;
-        let MethodName = 'tool-PinyinToVoiceFile';
-        let data = {
+      let MethodName = 'tool-TextToVoiceFile';
+      let data = {};
+      if (item.content.trim()) {
+        data = {
+          text: item.content.trim(),
+        };
+      } else if (item.pinyin.trim()) {
+        MethodName = 'tool-PinyinToVoiceFile';
+        data = {
           pinyin: item.pinyin.trim().split(' ').join(','),
         };
-        GetStaticResources(MethodName, data)
-          .then((res) => {
-            this.loading_list[i].loading = false;
-            if (res.status === 1) {
-              item.audio_file_id = res.file_id;
-              this.data.file_id_list.push(res.file_id);
-            }
-          })
-          .catch(() => {
-            this.loading_list[i].loading = false;
-          });
       }
+      this.loading_list[i].loading = true;
+      GetStaticResources(MethodName, data)
+        .then((res) => {
+          this.loading_list[i].loading = false;
+          if (res.status === 1) {
+            item.audio_file_id = res.file_id;
+            this.data.file_id_list.push(res.file_id);
+          }
+        })
+        .catch(() => {
+          this.loading_list[i].loading = false;
+        });
     },
     fileUploadSuccess(file_id, file_url, index) {
       this.data.file_id_list.push(file_id);

+ 21 - 15
src/views/exercise_questions/create/components/exercises/WordDictationQuestion.vue

@@ -243,24 +243,30 @@ export default {
     },
     // 自动生成音频
     handleMatically(item, i) {
-      if (item.pinyin.trim()) {
-        this.loading_list[i].loading = true;
-        let MethodName = 'tool-PinyinToVoiceFile';
-        let data = {
+      let MethodName = 'tool-TextToVoiceFile';
+      let data = {};
+      if (item.content.trim()) {
+        data = {
+          text: item.content.trim(),
+        };
+      } else if (item.pinyin.trim()) {
+        MethodName = 'tool-PinyinToVoiceFile';
+        data = {
           pinyin: item.pinyin.trim().split(' ').join(','),
         };
-        GetStaticResources(MethodName, data)
-          .then((res) => {
-            this.loading_list[i].loading = false;
-            if (res.status === 1) {
-              item.audio_file_id = res.file_id;
-              this.data.file_id_list.push(res.file_id);
-            }
-          })
-          .catch(() => {
-            this.loading_list[i].loading = false;
-          });
       }
+      this.loading_list[i].loading = true;
+      GetStaticResources(MethodName, data)
+        .then((res) => {
+          this.loading_list[i].loading = false;
+          if (res.status === 1) {
+            item.audio_file_id = res.file_id;
+            this.data.file_id_list.push(res.file_id);
+          }
+        })
+        .catch(() => {
+          this.loading_list[i].loading = false;
+        });
     },
 
     // 切割拼音