瀏覽代碼

给tts都加入语音指令参数(可空)

liyanbo 3 周之前
父節點
當前提交
44e4464498
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      src/components/study/SelfDirectedLearning.vue

+ 8 - 2
src/components/study/SelfDirectedLearning.vue

@@ -855,7 +855,7 @@ const generateVoiceover = async (lessonIndex, sectionIndex, dialogueIndex) => {
 
   const dialogue = section.dialogues[dialogueIndex]
 
-  // 只处理数字人对话和提问
+  // 只处理数字人对话和提问、诗词
   if (dialogue.type === 'user') {
     return
   }
@@ -869,10 +869,16 @@ const generateVoiceover = async (lessonIndex, sectionIndex, dialogueIndex) => {
     return
   }
   try {
+    // 根据对话类型设置不同的command
+    const command = dialogue.type === 'poem'
+        ? "要有感情的朗读诗词语句,要符合诗词的节奏和韵律。"
+        : null
+
     // 调用后端API将文本转成语音
     const response = await textToSpeech({
       roleId: role.id,
-      content: dialogue.content
+      content: dialogue.content,
+      command: command
     })
 
     // 将返回的URL赋值给对话