mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
update: 增加智能体独立音频设置
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package xiaozhi.modules.agent.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@@ -44,6 +45,15 @@ public class AgentUpdateDTO implements Serializable {
|
||||
@Schema(description = "音色语言", example = "普通话", nullable = true)
|
||||
private String ttsLanguage;
|
||||
|
||||
@Schema(description = "TTS音量", example = "50", nullable = true)
|
||||
private Integer ttsVolume;
|
||||
|
||||
@Schema(description = "TTS语速", example = "50", nullable = true)
|
||||
private Integer ttsRate;
|
||||
|
||||
@Schema(description = "TTS音调", example = "50", nullable = true)
|
||||
private Integer ttsPitch;
|
||||
|
||||
@Schema(description = "记忆模型标识", example = "mem_model_02", nullable = true)
|
||||
private String memModelId;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package xiaozhi.modules.agent.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
@@ -48,6 +49,15 @@ public class AgentEntity {
|
||||
@Schema(description = "音色语言")
|
||||
private String ttsLanguage;
|
||||
|
||||
@Schema(description = "TTS音量")
|
||||
private Integer ttsVolume;
|
||||
|
||||
@Schema(description = "TTS语速")
|
||||
private Integer ttsRate;
|
||||
|
||||
@Schema(description = "TTS音调")
|
||||
private Integer ttsPitch;
|
||||
|
||||
@Schema(description = "记忆模型标识")
|
||||
private String memModelId;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package xiaozhi.modules.agent.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
@@ -69,6 +70,21 @@ public class AgentTemplateEntity implements Serializable {
|
||||
*/
|
||||
private String ttsLanguage;
|
||||
|
||||
/**
|
||||
* TTS音量
|
||||
*/
|
||||
private Integer ttsVolume;
|
||||
|
||||
/**
|
||||
* TTS语速
|
||||
*/
|
||||
private Integer ttsRate;
|
||||
|
||||
/**
|
||||
* TTS音调
|
||||
*/
|
||||
private Integer ttsPitch;
|
||||
|
||||
/**
|
||||
* 记忆模型标识
|
||||
*/
|
||||
|
||||
+9
@@ -285,6 +285,15 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
||||
if (dto.getTtsLanguage() != null) {
|
||||
existingEntity.setTtsLanguage(dto.getTtsLanguage());
|
||||
}
|
||||
if (dto.getTtsVolume() != null) {
|
||||
existingEntity.setTtsVolume(dto.getTtsVolume());
|
||||
}
|
||||
if (dto.getTtsRate() != null) {
|
||||
existingEntity.setTtsRate(dto.getTtsRate());
|
||||
}
|
||||
if (dto.getTtsPitch() != null) {
|
||||
existingEntity.setTtsPitch(dto.getTtsPitch());
|
||||
}
|
||||
if (dto.getMemModelId() != null) {
|
||||
existingEntity.setMemModelId(dto.getMemModelId());
|
||||
}
|
||||
|
||||
+15
@@ -88,6 +88,9 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
agent.getVadModelId(),
|
||||
agent.getAsrModelId(),
|
||||
null,
|
||||
@@ -219,6 +222,9 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
referenceAudio,
|
||||
referenceText,
|
||||
language,
|
||||
agent.getTtsVolume(),
|
||||
agent.getTtsRate(),
|
||||
agent.getTtsPitch(),
|
||||
agent.getVadModelId(),
|
||||
agent.getAsrModelId(),
|
||||
agent.getLlmModelId(),
|
||||
@@ -397,6 +403,9 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
String referenceAudio,
|
||||
String referenceText,
|
||||
String language,
|
||||
Integer ttsVolume,
|
||||
Integer ttsRate,
|
||||
Integer ttsPitch,
|
||||
String vadModelId,
|
||||
String asrModelId,
|
||||
String llmModelId,
|
||||
@@ -437,6 +446,12 @@ public class ConfigServiceImpl implements ConfigService {
|
||||
((Map<String, Object>) model.getConfigJson()).put("ref_text", referenceText);
|
||||
if (language != null)
|
||||
((Map<String, Object>) model.getConfigJson()).put("language", language);
|
||||
if (ttsVolume != null)
|
||||
((Map<String, Object>) model.getConfigJson()).put("ttsVolume", ttsVolume);
|
||||
if (ttsRate != null)
|
||||
((Map<String, Object>) model.getConfigJson()).put("ttsRate", ttsRate);
|
||||
if (ttsPitch != null)
|
||||
((Map<String, Object>) model.getConfigJson()).put("ttsPitch", ttsPitch);
|
||||
|
||||
// 火山引擎声音克隆需要替换resource_id
|
||||
Map<String, Object> map = (Map<String, Object>) model.getConfigJson();
|
||||
|
||||
@@ -13,8 +13,36 @@ SET languages = CASE
|
||||
ELSE languages
|
||||
END;
|
||||
|
||||
-- 添加音色语言字段到 ai_agent 表
|
||||
ALTER TABLE `ai_agent` ADD COLUMN `tts_language` VARCHAR(50) NULL COMMENT '音色语言' AFTER `tts_voice_id`;
|
||||
-- 添加音色语言、音量、语速、音调字段到 ai_agent 表
|
||||
SET @col_exists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ai_agent' AND COLUMN_NAME = 'tts_language');
|
||||
SET @sql = IF(@col_exists = 0, 'ALTER TABLE `ai_agent` ADD COLUMN `tts_language` VARCHAR(50) NULL COMMENT ''音色语言'' AFTER `tts_voice_id`', 'SELECT ''Column tts_language already exists'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 添加音色语言字段到 ai_agent_template 表
|
||||
ALTER TABLE `ai_agent_template` ADD COLUMN `tts_language` VARCHAR(50) NULL COMMENT '音色语言' AFTER `tts_voice_id`;
|
||||
SET @col_exists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ai_agent' AND COLUMN_NAME = 'tts_volume');
|
||||
SET @sql = IF(@col_exists = 0, 'ALTER TABLE `ai_agent` ADD COLUMN `tts_volume` INT NULL COMMENT ''TTS音量'' AFTER `tts_language`', 'SELECT ''Column tts_volume already exists'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col_exists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ai_agent' AND COLUMN_NAME = 'tts_rate');
|
||||
SET @sql = IF(@col_exists = 0, 'ALTER TABLE `ai_agent` ADD COLUMN `tts_rate` INT NULL COMMENT ''TTS语速'' AFTER `tts_volume`', 'SELECT ''Column tts_rate already exists'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col_exists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ai_agent' AND COLUMN_NAME = 'tts_pitch');
|
||||
SET @sql = IF(@col_exists = 0, 'ALTER TABLE `ai_agent` ADD COLUMN `tts_pitch` INT NULL COMMENT ''TTS音调'' AFTER `tts_rate`', 'SELECT ''Column tts_pitch already exists'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
-- 添加音色语言、音量、语速、音调字段到 ai_agent_template 表
|
||||
SET @col_exists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ai_agent_template' AND COLUMN_NAME = 'tts_language');
|
||||
SET @sql = IF(@col_exists = 0, 'ALTER TABLE `ai_agent_template` ADD COLUMN `tts_language` VARCHAR(50) NULL COMMENT ''音色语言'' AFTER `tts_voice_id`', 'SELECT ''Column tts_language already exists'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col_exists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ai_agent_template' AND COLUMN_NAME = 'tts_volume');
|
||||
SET @sql = IF(@col_exists = 0, 'ALTER TABLE `ai_agent_template` ADD COLUMN `tts_volume` INT NULL COMMENT ''TTS音量'' AFTER `tts_language`', 'SELECT ''Column tts_volume already exists'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col_exists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ai_agent_template' AND COLUMN_NAME = 'tts_rate');
|
||||
SET @sql = IF(@col_exists = 0, 'ALTER TABLE `ai_agent_template` ADD COLUMN `tts_rate` INT NULL COMMENT ''TTS语速'' AFTER `tts_volume`', 'SELECT ''Column tts_rate already exists'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
|
||||
SET @col_exists = (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'ai_agent_template' AND COLUMN_NAME = 'tts_pitch');
|
||||
SET @sql = IF(@col_exists = 0, 'ALTER TABLE `ai_agent_template` ADD COLUMN `tts_pitch` INT NULL COMMENT ''TTS音调'' AFTER `tts_rate`', 'SELECT ''Column tts_pitch already exists'' AS msg');
|
||||
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
||||
@@ -17,6 +17,9 @@
|
||||
<result column="ttsModelId" property="ttsModelId"/>
|
||||
<result column="ttsVoiceId" property="ttsVoiceId"/>
|
||||
<result column="ttsLanguage" property="ttsLanguage"/>
|
||||
<result column="ttsVolume" property="ttsVolume"/>
|
||||
<result column="ttsRate" property="ttsRate"/>
|
||||
<result column="ttsPitch" property="ttsPitch"/>
|
||||
<result column="memModelId" property="memModelId"/>
|
||||
<result column="intentModelId" property="intentModelId"/>
|
||||
|
||||
@@ -47,6 +50,9 @@
|
||||
a.tts_model_id AS ttsModelId,
|
||||
a.tts_voice_id AS ttsVoiceId,
|
||||
a.tts_language AS ttsLanguage,
|
||||
a.tts_volume AS ttsVolume,
|
||||
a.tts_rate AS ttsRate,
|
||||
a.tts_pitch AS ttsPitch,
|
||||
a.mem_model_id AS memModelId,
|
||||
a.intent_model_id AS intentModelId,
|
||||
COALESCE(
|
||||
|
||||
Reference in New Issue
Block a user