소스 검색

tts管理接入豆包平台参数(情感、语音指令)

liyanbo 3 주 전
부모
커밋
84c303e3af

+ 6 - 0
byzs-module-ai/src/main/java/cn/iocoder/byzs/module/ai/controller/admin/tts/vo/AiTtsPageReqVO.java

@@ -44,4 +44,10 @@ public class AiTtsPageReqVO extends PageParam {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime[] createTime;
 
+    @Schema(description = "情感")
+    private String emotion;
+
+    @Schema(description = "语音指令")
+    private String command;
+
 }

+ 8 - 0
byzs-module-ai/src/main/java/cn/iocoder/byzs/module/ai/controller/admin/tts/vo/AiTtsRespVO.java

@@ -63,4 +63,12 @@ public class AiTtsRespVO {
     @Schema(description = "租户id")
     private Long tenantId;
 
+    @Schema(description = "情感")
+    @ExcelProperty("情感")
+    private String emotion;
+
+    @Schema(description = "语音指令")
+    @ExcelProperty("语音指令")
+    private String command;
+
 }

+ 6 - 0
byzs-module-ai/src/main/java/cn/iocoder/byzs/module/ai/controller/admin/tts/vo/AiTtsSaveReqVO.java

@@ -42,4 +42,10 @@ public class AiTtsSaveReqVO {
     @Schema(description = "音量")
     private Integer pitchRate;
 
+    @Schema(description = "情感")
+    private String emotion;
+
+    @Schema(description = "语音指令")
+    private String command;
+
 }

+ 10 - 0
byzs-module-ai/src/main/java/cn/iocoder/byzs/module/ai/dal/dataobject/tts/AiTtsDO.java

@@ -72,5 +72,15 @@ public class AiTtsDO extends BaseDO {
      */
     private Integer pitchRate;
 
+    /**
+     * 情感
+     */
+    private String emotion;
+
+    /**
+     * 语音指令
+     */
+    private String command;
+
 
 }

+ 2 - 0
byzs-module-ai/src/main/java/cn/iocoder/byzs/module/ai/dal/mysql/tts/AiTtsMapper.java

@@ -28,6 +28,8 @@ public interface AiTtsMapper extends BaseMapperX<AiTtsDO> {
                 .eqIfPresent(AiTtsDO::getSpeechRate, reqVO.getSpeechRate())
                 .eqIfPresent(AiTtsDO::getVolume, reqVO.getVolume())
                 .eqIfPresent(AiTtsDO::getPitchRate, reqVO.getPitchRate())
+                .likeIfPresent(AiTtsDO::getEmotion, reqVO.getEmotion())
+                .likeIfPresent(AiTtsDO::getCommand, reqVO.getCommand())
                 .betweenIfPresent(AiTtsDO::getCreateTime, reqVO.getCreateTime())
                 .orderByAsc(AiTtsDO::getSort));
     }

+ 5 - 1
byzs-module-ai/src/main/java/cn/iocoder/byzs/module/ai/service/tts/DouBaoTtsService.java

@@ -55,7 +55,9 @@ public class DouBaoTtsService {
         Map<String, Object> audioParams = new HashMap<>();
         audioParams.put("format", "mp3"); // 输出音频格式
         audioParams.put("sample_rate", 16000); // 推荐采样率
-//        audioParams.put("emotion", "开心");
+        if (aiTtsDO.getEmotion() != null && !aiTtsDO.getEmotion().isEmpty()) {
+            audioParams.put("emotion", aiTtsDO.getEmotion());
+        }
 
         // 语速和音量参数
         if (aiTtsDO.getSpeechRate() != null) {
@@ -77,6 +79,8 @@ public class DouBaoTtsService {
         //语音指令
         if (command != null && !command.isEmpty()) {
             additions.put("context_texts", List.of(command));
+        }else if (aiTtsDO.getCommand() != null && !aiTtsDO.getCommand().isEmpty()){
+            additions.put("context_texts", List.of(aiTtsDO.getCommand()));
         }
 
         // 将 additions 映射序列化为 JSON 字符串