mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +01:00
Merge branch 'xinnan-tech:main' into main
This commit is contained in:
commit
af3e47e4d4
66 changed files with 1852 additions and 128 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -3,6 +3,9 @@ __pycache__/
|
|||
.idea/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
.vscode
|
||||
.claude
|
||||
AGENTS.md
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
|
|
|||
|
|
@ -245,4 +245,9 @@ public interface ErrorCode {
|
|||
int DEVICE_NOT_EXIST = 10194; // 设备不存在
|
||||
int OTA_UPLOAD_COUNT_EXCEED = 10195; // OTA上传次数超过限制
|
||||
|
||||
// 智能体标签相关错误码
|
||||
int AGENT_TAG_NAME_DUPLICATE = 10196; // 标签名称已存在
|
||||
int AGENT_TAG_NAME_EMPTY = 10197; // 标签名称不能为空
|
||||
int AGENT_TAG_NOT_EXIST = 10198; // 标签不存在
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,9 @@ import xiaozhi.modules.agent.dto.AgentMemoryDTO;
|
|||
import xiaozhi.modules.agent.dto.AgentUpdateDTO;
|
||||
import xiaozhi.modules.agent.entity.AgentEntity;
|
||||
import xiaozhi.modules.agent.entity.AgentTemplateEntity;
|
||||
import xiaozhi.modules.agent.dto.AgentTagDTO;
|
||||
import xiaozhi.modules.agent.entity.AgentTagEntity;
|
||||
import xiaozhi.modules.agent.service.AgentTagService;
|
||||
import xiaozhi.modules.agent.service.AgentChatAudioService;
|
||||
import xiaozhi.modules.agent.service.AgentChatHistoryService;
|
||||
import xiaozhi.modules.agent.service.AgentChatSummaryService;
|
||||
|
|
@ -69,6 +72,7 @@ public class AgentController {
|
|||
private final AgentContextProviderService agentContextProviderService;
|
||||
private final AgentChatSummaryService agentChatSummaryService;
|
||||
private final RedisUtils redisUtils;
|
||||
private final AgentTagService agentTagService;
|
||||
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获取用户智能体列表")
|
||||
|
|
@ -275,6 +279,50 @@ public class AgentController {
|
|||
.body(audioData);
|
||||
}
|
||||
|
||||
@PostMapping("/tag")
|
||||
@Operation(summary = "创建标签")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<AgentTagEntity> createTag(@RequestBody Map<String, String> params) {
|
||||
String tagName = params.get("tagName");
|
||||
if (StringUtils.isBlank(tagName)) {
|
||||
return new Result<AgentTagEntity>().error("标签名称不能为空");
|
||||
}
|
||||
AgentTagEntity tag = agentTagService.saveTag(tagName);
|
||||
return new Result<AgentTagEntity>().ok(tag);
|
||||
}
|
||||
|
||||
@GetMapping("/tag/list")
|
||||
@Operation(summary = "获取所有标签列表")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<List<AgentTagDTO>> getAllTags() {
|
||||
List<AgentTagDTO> tags = agentTagService.getAllTags();
|
||||
return new Result<List<AgentTagDTO>>().ok(tags);
|
||||
}
|
||||
|
||||
@DeleteMapping("/tag/{id}")
|
||||
@Operation(summary = "删除标签")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<Void> deleteTag(@PathVariable String id) {
|
||||
agentTagService.deleteTag(id);
|
||||
return new Result<Void>().ok(null);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/tags")
|
||||
@Operation(summary = "获取智能体的标签")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<List<AgentTagDTO>> getAgentTags(@PathVariable String id) {
|
||||
List<AgentTagDTO> tags = agentTagService.getTagsByAgentId(id);
|
||||
return new Result<List<AgentTagDTO>>().ok(tags);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/tags")
|
||||
@Operation(summary = "保存智能体的标签")
|
||||
@RequiresPermissions("sys:role:normal")
|
||||
public Result<Void> saveAgentTags(@PathVariable String id, @RequestBody Map<String, Object> params) {
|
||||
List<String> tagIds = (List<String>) params.get("tagIds");
|
||||
List<String> tagNames = (List<String>) params.get("tagNames");
|
||||
agentTagService.saveAgentTags(id, tagIds, tagNames);
|
||||
return new Result<Void>().ok(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
package xiaozhi.modules.agent.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import xiaozhi.common.dao.BaseDao;
|
||||
import xiaozhi.modules.agent.entity.AgentTagEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AgentTagDao extends BaseDao<AgentTagEntity> {
|
||||
|
||||
List<AgentTagEntity> selectByAgentId(@Param("agentId") String agentId);
|
||||
|
||||
List<AgentTagEntity> selectByAgentIds(@Param("agentIds") List<String> agentIds);
|
||||
|
||||
List<AgentTagEntity> selectAll();
|
||||
|
||||
List<String> selectAgentIdsByTagName(@Param("tagName") String tagName);
|
||||
|
||||
List<AgentTagEntity> selectByTagNames(@Param("tagNames") List<String> tagNames);
|
||||
|
||||
int batchInsert(@Param("list") List<AgentTagEntity> tagList);
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package xiaozhi.modules.agent.dao;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import xiaozhi.common.dao.BaseDao;
|
||||
import xiaozhi.modules.agent.entity.AgentTagRelationEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AgentTagRelationDao extends BaseDao<AgentTagRelationEntity> {
|
||||
|
||||
int deleteByAgentId(@Param("agentId") String agentId);
|
||||
|
||||
int insertRelation(AgentTagRelationEntity relation);
|
||||
|
||||
int batchInsertRelation(@Param("list") List<AgentTagRelationEntity> relations);
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import xiaozhi.modules.agent.dto.AgentTagDTO;
|
||||
|
||||
/**
|
||||
* 智能体数据传输对象
|
||||
|
|
@ -46,4 +47,7 @@ public class AgentDTO {
|
|||
|
||||
@Schema(description = "设备数量", example = "10")
|
||||
private Integer deviceCount;
|
||||
|
||||
@Schema(description = "标签列表")
|
||||
private List<AgentTagDTO> tags;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package xiaozhi.modules.agent.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Schema(description = "智能体标签DTO")
|
||||
public class AgentTagDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "标签ID")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "标签名称")
|
||||
private String tagName;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
@ -41,6 +42,18 @@ public class AgentUpdateDTO implements Serializable {
|
|||
@Schema(description = "音色标识", example = "voice_02", nullable = true)
|
||||
private String ttsVoiceId;
|
||||
|
||||
@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;
|
||||
|
|
@ -45,6 +46,18 @@ public class AgentEntity {
|
|||
@Schema(description = "音色标识")
|
||||
private String ttsVoiceId;
|
||||
|
||||
@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;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package xiaozhi.modules.agent.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("ai_agent_tag")
|
||||
@Schema(description = "智能体标签")
|
||||
public class AgentTagEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "标签名称")
|
||||
private String tagName;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
private Long creator;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createdAt;
|
||||
|
||||
@Schema(description = "更新者")
|
||||
private Long updater;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private Date updatedAt;
|
||||
|
||||
@Schema(description = "删除标记")
|
||||
private Integer deleted;
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package xiaozhi.modules.agent.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("ai_agent_tag_relation")
|
||||
@Schema(description = "智能体标签关联")
|
||||
public class AgentTagRelationEntity {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "智能体ID")
|
||||
private String agentId;
|
||||
|
||||
@Schema(description = "标签ID")
|
||||
private String tagId;
|
||||
|
||||
@Schema(description = "创建者")
|
||||
private Long creator;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createdAt;
|
||||
|
||||
@Schema(description = "更新者")
|
||||
private Long updater;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private Date updatedAt;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -64,6 +65,26 @@ public class AgentTemplateEntity implements Serializable {
|
|||
*/
|
||||
private String ttsVoiceId;
|
||||
|
||||
/**
|
||||
* 音色语言
|
||||
*/
|
||||
private String ttsLanguage;
|
||||
|
||||
/**
|
||||
* TTS音量
|
||||
*/
|
||||
private Integer ttsVolume;
|
||||
|
||||
/**
|
||||
* TTS语速
|
||||
*/
|
||||
private Integer ttsRate;
|
||||
|
||||
/**
|
||||
* TTS音调
|
||||
*/
|
||||
private Integer ttsPitch;
|
||||
|
||||
/**
|
||||
* 记忆模型标识
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package xiaozhi.modules.agent.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import xiaozhi.modules.agent.dto.AgentTagDTO;
|
||||
import xiaozhi.modules.agent.entity.AgentTagEntity;
|
||||
|
||||
public interface AgentTagService {
|
||||
|
||||
AgentTagEntity saveTag(String tagName);
|
||||
|
||||
void deleteTag(String tagId);
|
||||
|
||||
List<AgentTagDTO> getTagsByAgentId(String agentId);
|
||||
|
||||
void saveAgentTags(String agentId, List<String> tagIds, List<String> tagNames);
|
||||
|
||||
void deleteAgentTags(String agentId);
|
||||
|
||||
List<AgentTagDTO> getTagsByAgentIds(List<String> agentIds);
|
||||
|
||||
List<AgentTagDTO> getAllTags();
|
||||
|
||||
List<String> getAgentIdsByTagName(String tagName);
|
||||
}
|
||||
|
|
@ -31,17 +31,21 @@ import xiaozhi.common.utils.ConvertUtils;
|
|||
import xiaozhi.common.utils.JsonUtils;
|
||||
import xiaozhi.common.utils.ToolUtil;
|
||||
import xiaozhi.modules.agent.dao.AgentDao;
|
||||
import xiaozhi.modules.agent.dao.AgentTagDao;
|
||||
import xiaozhi.modules.agent.dto.AgentCreateDTO;
|
||||
import xiaozhi.modules.agent.dto.AgentDTO;
|
||||
import xiaozhi.modules.agent.dto.AgentTagDTO;
|
||||
import xiaozhi.modules.agent.dto.AgentUpdateDTO;
|
||||
import xiaozhi.modules.agent.entity.AgentContextProviderEntity;
|
||||
import xiaozhi.modules.agent.entity.AgentEntity;
|
||||
import xiaozhi.modules.agent.entity.AgentPluginMapping;
|
||||
import xiaozhi.modules.agent.entity.AgentTagEntity;
|
||||
import xiaozhi.modules.agent.entity.AgentTemplateEntity;
|
||||
import xiaozhi.modules.agent.service.AgentChatHistoryService;
|
||||
import xiaozhi.modules.agent.service.AgentContextProviderService;
|
||||
import xiaozhi.modules.agent.service.AgentPluginMappingService;
|
||||
import xiaozhi.modules.agent.service.AgentService;
|
||||
import xiaozhi.modules.agent.service.AgentTagService;
|
||||
import xiaozhi.modules.agent.service.AgentTemplateService;
|
||||
import xiaozhi.modules.agent.vo.AgentInfoVO;
|
||||
import xiaozhi.modules.device.entity.DeviceEntity;
|
||||
|
|
@ -59,6 +63,7 @@ import xiaozhi.modules.timbre.service.TimbreService;
|
|||
@AllArgsConstructor
|
||||
public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> implements AgentService {
|
||||
private final AgentDao agentDao;
|
||||
private final AgentTagDao agentTagDao;
|
||||
private final TimbreService timbreModelService;
|
||||
private final ModelConfigService modelConfigService;
|
||||
private final RedisUtils redisUtils;
|
||||
|
|
@ -68,6 +73,7 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
|||
private final AgentTemplateService agentTemplateService;
|
||||
private final ModelProviderService modelProviderService;
|
||||
private final AgentContextProviderService agentContextProviderService;
|
||||
private final AgentTagService agentTagService;
|
||||
|
||||
@Override
|
||||
public PageData<AgentEntity> adminAgentList(Map<String, Object> params) {
|
||||
|
|
@ -151,8 +157,16 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
|||
return new ArrayList<>();
|
||||
}
|
||||
} else {
|
||||
// 按名称搜索
|
||||
queryWrapper.like("agent_name", keyword);
|
||||
// 按名称搜索(默认):同时搜索智能体名称和标签名
|
||||
List<String> tagAgentIds = agentTagService.getAgentIdsByTagName(keyword);
|
||||
if (ToolUtil.isNotEmpty(tagAgentIds)) {
|
||||
queryWrapper.and(wrapper -> wrapper
|
||||
.like("agent_name", keyword)
|
||||
.or()
|
||||
.in("id", tagAgentIds));
|
||||
} else {
|
||||
queryWrapper.like("agent_name", keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,6 +207,19 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
|||
// 获取设备数量
|
||||
dto.setDeviceCount(getDeviceCountByAgentId(agent.getId()));
|
||||
|
||||
// 获取标签列表
|
||||
List<AgentTagEntity> tags = agentTagDao.selectByAgentId(agent.getId());
|
||||
if (ToolUtil.isNotEmpty(tags)) {
|
||||
dto.setTags(tags.stream().map(this::convertTagToDTO).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
private AgentTagDTO convertTagToDTO(AgentTagEntity entity) {
|
||||
AgentTagDTO dto = new AgentTagDTO();
|
||||
dto.setId(entity.getId());
|
||||
dto.setTagName(entity.getTagName());
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
|
@ -282,6 +309,18 @@ public class AgentServiceImpl extends BaseServiceImpl<AgentDao, AgentEntity> imp
|
|||
if (dto.getTtsVoiceId() != null) {
|
||||
existingEntity.setTtsVoiceId(dto.getTtsVoiceId());
|
||||
}
|
||||
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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,199 @@
|
|||
package xiaozhi.modules.agent.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import xiaozhi.common.exception.ErrorCode;
|
||||
import xiaozhi.common.exception.RenException;
|
||||
import xiaozhi.common.service.impl.BaseServiceImpl;
|
||||
import xiaozhi.modules.agent.dao.AgentTagDao;
|
||||
import xiaozhi.modules.agent.dao.AgentTagRelationDao;
|
||||
import xiaozhi.modules.agent.dto.AgentTagDTO;
|
||||
import xiaozhi.modules.agent.entity.AgentTagEntity;
|
||||
import xiaozhi.modules.agent.entity.AgentTagRelationEntity;
|
||||
import xiaozhi.modules.agent.service.AgentTagService;
|
||||
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class AgentTagServiceImpl extends BaseServiceImpl<AgentTagDao, AgentTagEntity> implements AgentTagService {
|
||||
|
||||
private final AgentTagRelationDao agentTagRelationDao;
|
||||
|
||||
@Override
|
||||
public AgentTagEntity saveTag(String tagName) {
|
||||
if (tagName == null || tagName.trim().isEmpty()) {
|
||||
throw new RenException(ErrorCode.AGENT_TAG_NAME_EMPTY);
|
||||
}
|
||||
|
||||
QueryWrapper<AgentTagEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("tag_name", tagName);
|
||||
wrapper.eq("deleted", 0);
|
||||
AgentTagEntity existTag = baseDao.selectOne(wrapper);
|
||||
if (existTag != null) {
|
||||
return existTag;
|
||||
}
|
||||
|
||||
AgentTagEntity tag = new AgentTagEntity();
|
||||
tag.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
tag.setTagName(tagName);
|
||||
tag.setSort(0);
|
||||
tag.setCreatedAt(new Date());
|
||||
tag.setUpdatedAt(new Date());
|
||||
tag.setDeleted(0);
|
||||
baseDao.insert(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTag(String tagId) {
|
||||
AgentTagEntity tag = baseDao.selectById(tagId);
|
||||
if (tag != null) {
|
||||
tag.setDeleted(1);
|
||||
tag.setUpdatedAt(new Date());
|
||||
baseDao.updateById(tag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AgentTagDTO> getTagsByAgentId(String agentId) {
|
||||
List<AgentTagEntity> tags = baseDao.selectByAgentId(agentId);
|
||||
return tags.stream().map(this::convertToDTO).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveAgentTags(String agentId, List<String> tagIds, List<String> tagNames) {
|
||||
agentTagRelationDao.deleteByAgentId(agentId);
|
||||
|
||||
List<AgentTagEntity> currentTags = baseDao.selectByAgentId(agentId);
|
||||
List<String> currentTagNames = currentTags.stream()
|
||||
.map(AgentTagEntity::getTagName)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<String> allTagIds = new ArrayList<>();
|
||||
List<String> newTagNames = new ArrayList<>();
|
||||
|
||||
if (tagNames != null && !tagNames.isEmpty()) {
|
||||
Set<String> addedTagNames = new HashSet<>();
|
||||
for (String tagName : tagNames) {
|
||||
if (tagName == null || tagName.trim().isEmpty()) {
|
||||
throw new RenException(ErrorCode.AGENT_TAG_NAME_EMPTY);
|
||||
}
|
||||
|
||||
if (currentTagNames.contains(tagName) || addedTagNames.contains(tagName)) {
|
||||
throw new RenException(ErrorCode.AGENT_TAG_NAME_DUPLICATE);
|
||||
}
|
||||
addedTagNames.add(tagName);
|
||||
newTagNames.add(tagName);
|
||||
}
|
||||
}
|
||||
|
||||
List<AgentTagEntity> existTags = new ArrayList<>();
|
||||
if (!newTagNames.isEmpty()) {
|
||||
existTags = baseDao.selectByTagNames(newTagNames);
|
||||
}
|
||||
|
||||
List<String> existTagNames = existTags.stream()
|
||||
.map(AgentTagEntity::getTagName)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<AgentTagEntity> tagsToInsert = new ArrayList<>();
|
||||
for (String tagName : newTagNames) {
|
||||
if (!existTagNames.contains(tagName)) {
|
||||
AgentTagEntity tag = new AgentTagEntity();
|
||||
tag.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
tag.setTagName(tagName);
|
||||
tag.setSort(0);
|
||||
tag.setDeleted(0);
|
||||
tag.setCreatedAt(new Date());
|
||||
tag.setUpdatedAt(new Date());
|
||||
tagsToInsert.add(tag);
|
||||
}
|
||||
}
|
||||
|
||||
if (!tagsToInsert.isEmpty()) {
|
||||
baseDao.batchInsert(tagsToInsert);
|
||||
for (AgentTagEntity tag : tagsToInsert) {
|
||||
allTagIds.add(tag.getId());
|
||||
}
|
||||
}
|
||||
|
||||
for (AgentTagEntity existTag : existTags) {
|
||||
if (!allTagIds.contains(existTag.getId())) {
|
||||
allTagIds.add(existTag.getId());
|
||||
}
|
||||
}
|
||||
|
||||
if (tagIds != null && !tagIds.isEmpty()) {
|
||||
List<AgentTagEntity> tagIdEntities = baseDao.selectBatchIds(tagIds);
|
||||
for (AgentTagEntity tag : tagIdEntities) {
|
||||
if (tag != null && (currentTagNames.contains(tag.getTagName()) ||
|
||||
newTagNames.contains(tag.getTagName()))) {
|
||||
throw new RenException(ErrorCode.AGENT_TAG_NAME_DUPLICATE);
|
||||
}
|
||||
}
|
||||
allTagIds.addAll(tagIds);
|
||||
}
|
||||
|
||||
if (allTagIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<AgentTagRelationEntity> relations = new ArrayList<>();
|
||||
Date now = new Date();
|
||||
for (String tagId : allTagIds) {
|
||||
AgentTagRelationEntity relation = new AgentTagRelationEntity();
|
||||
relation.setId(UUID.randomUUID().toString().replace("-", ""));
|
||||
relation.setAgentId(agentId);
|
||||
relation.setTagId(tagId);
|
||||
relation.setCreatedAt(now);
|
||||
relation.setUpdatedAt(now);
|
||||
relations.add(relation);
|
||||
}
|
||||
agentTagRelationDao.batchInsertRelation(relations);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAgentTags(String agentId) {
|
||||
agentTagRelationDao.deleteByAgentId(agentId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AgentTagDTO> getTagsByAgentIds(List<String> agentIds) {
|
||||
if (agentIds == null || agentIds.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
List<AgentTagEntity> tags = baseDao.selectByAgentIds(agentIds);
|
||||
return tags.stream().map(this::convertToDTO).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AgentTagDTO> getAllTags() {
|
||||
List<AgentTagEntity> tags = baseDao.selectAll();
|
||||
return tags.stream().map(this::convertToDTO).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAgentIdsByTagName(String tagName) {
|
||||
return baseDao.selectAgentIdsByTagName(tagName);
|
||||
}
|
||||
|
||||
private AgentTagDTO convertToDTO(AgentTagEntity entity) {
|
||||
AgentTagDTO dto = new AgentTagDTO();
|
||||
dto.setId(entity.getId());
|
||||
dto.setTagName(entity.getTagName());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
|
@ -87,6 +87,10 @@ public class ConfigServiceImpl implements ConfigService {
|
|||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
agent.getVadModelId(),
|
||||
agent.getAsrModelId(),
|
||||
null,
|
||||
|
|
@ -135,15 +139,24 @@ public class ConfigServiceImpl implements ConfigService {
|
|||
String voice = null;
|
||||
String referenceAudio = null;
|
||||
String referenceText = null;
|
||||
String language = null;
|
||||
TimbreDetailsVO timbre = timbreService.get(agent.getTtsVoiceId());
|
||||
if (timbre != null) {
|
||||
voice = timbre.getTtsVoice();
|
||||
referenceAudio = timbre.getReferenceAudio();
|
||||
referenceText = timbre.getReferenceText();
|
||||
// 优先使用用户选择的语言,如果没有则使用音色支持的第一个语言
|
||||
if (StringUtils.isNotBlank(agent.getTtsLanguage())) {
|
||||
language = agent.getTtsLanguage();
|
||||
} else if (StringUtils.isNotBlank(timbre.getLanguages())) {
|
||||
language = timbre.getLanguages().split("、")[0].trim();
|
||||
}
|
||||
} else {
|
||||
VoiceCloneEntity voice_print = cloneVoiceService.selectById(agent.getTtsVoiceId());
|
||||
if (voice_print != null) {
|
||||
voice = voice_print.getVoiceId();
|
||||
// 优先使用用户选择的语言,如果没有则使用默认值
|
||||
language = StringUtils.isNotBlank(agent.getTtsLanguage()) ? agent.getTtsLanguage() : "普通话";
|
||||
}
|
||||
}
|
||||
// 构建返回数据
|
||||
|
|
@ -208,6 +221,10 @@ public class ConfigServiceImpl implements ConfigService {
|
|||
voice,
|
||||
referenceAudio,
|
||||
referenceText,
|
||||
language,
|
||||
agent.getTtsVolume(),
|
||||
agent.getTtsRate(),
|
||||
agent.getTtsPitch(),
|
||||
agent.getVadModelId(),
|
||||
agent.getAsrModelId(),
|
||||
agent.getLlmModelId(),
|
||||
|
|
@ -385,6 +402,10 @@ public class ConfigServiceImpl implements ConfigService {
|
|||
String voice,
|
||||
String referenceAudio,
|
||||
String referenceText,
|
||||
String language,
|
||||
Integer ttsVolume,
|
||||
Integer ttsRate,
|
||||
Integer ttsPitch,
|
||||
String vadModelId,
|
||||
String asrModelId,
|
||||
String llmModelId,
|
||||
|
|
@ -423,6 +444,14 @@ public class ConfigServiceImpl implements ConfigService {
|
|||
((Map<String, Object>) model.getConfigJson()).put("ref_audio", referenceAudio);
|
||||
if (referenceText != null)
|
||||
((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();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ public class VoiceDTO implements Serializable {
|
|||
@Schema(description = "音频播放地址")
|
||||
private String voiceDemo;
|
||||
|
||||
@Schema(description = "语言类型")
|
||||
private String languages;
|
||||
|
||||
@Schema(description = "是否为克隆音色")
|
||||
private Boolean isClone;
|
||||
|
||||
|
|
@ -31,6 +34,7 @@ public class VoiceDTO implements Serializable {
|
|||
this.id = id;
|
||||
this.name = name;
|
||||
this.voiceDemo = null;
|
||||
this.languages = null;
|
||||
this.isClone = false; // 默认不是克隆音色
|
||||
}
|
||||
|
||||
|
|
@ -39,6 +43,7 @@ public class VoiceDTO implements Serializable {
|
|||
this.id = id;
|
||||
this.name = name;
|
||||
this.voiceDemo = voiceDemo;
|
||||
this.languages = null;
|
||||
this.isClone = false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ public class TimbreServiceImpl extends BaseServiceImpl<TimbreDao, TimbreEntity>
|
|||
.map(entity -> {
|
||||
VoiceDTO dto = new VoiceDTO(entity.getId(), entity.getName());
|
||||
dto.setVoiceDemo(entity.getVoiceDemo());
|
||||
dto.setLanguages(entity.getLanguages()); // 设置语言类型
|
||||
dto.setIsClone(false); // 设置为普通音色
|
||||
return dto;
|
||||
})
|
||||
|
|
@ -146,6 +147,7 @@ public class TimbreServiceImpl extends BaseServiceImpl<TimbreDao, TimbreEntity>
|
|||
voiceDTO.setName(MessageUtils.getMessage(ErrorCode.VOICE_CLONE_PREFIX) + entity.getName());
|
||||
// 保留从数据库查询到的voiceDemo字段
|
||||
voiceDTO.setVoiceDemo(entity.getVoiceDemo());
|
||||
voiceDTO.setLanguages(entity.getLanguages());
|
||||
voiceDTO.setIsClone(true); // 设置为克隆音色
|
||||
redisUtils.set(RedisKeys.getTimbreNameById(voiceDTO.getId()), voiceDTO.getName(),
|
||||
RedisUtils.NOT_EXPIRE);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
-- 统一规范ai_tts_voice语言类型数据
|
||||
UPDATE ai_tts_voice
|
||||
SET languages = CASE
|
||||
WHEN languages IN ('中文', '普通话','东北话','天津话','中文-北京口音','中文-青岛口音','中文-河南口音','中文-广西口音','辽宁','陕西','中文-四川口音','中文-台湾口音','中文-长沙口音') THEN '普通话'
|
||||
WHEN languages IN ('中文及中英文混合', '中文、英文', '中文、美式英语','中文-北京口音、英文','中文(东北)及中英文混合') THEN '普通话、英语'
|
||||
WHEN languages IN ('英式英文', '英式英语', '美式英语', '澳洲英语', '英文') THEN '英语'
|
||||
WHEN languages = '日语' THEN '日语'
|
||||
WHEN languages = '日语、西语' THEN '日语、西班牙语'
|
||||
WHEN languages = '韩语' THEN '韩语'
|
||||
WHEN languages IN ('粤语', '中文-广东口音') THEN '粤语'
|
||||
WHEN languages = '中文(粤语)及中英文混合' THEN '粤语、英语'
|
||||
WHEN languages = '粤语及粤英混合' THEN '粤语、英语'
|
||||
ELSE languages
|
||||
END;
|
||||
|
||||
-- 添加音色语言、音量、语速、音调字段到 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;
|
||||
|
||||
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;
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
-- 更新腾讯TTS供应器配置,增加speed、volume和format参数
|
||||
UPDATE `ai_model_provider`
|
||||
SET fields = '[{"key":"appid","label":"应用ID","type":"string"},{"key":"secret_id","label":"Secret ID","type":"string"},{"key":"secret_key","label":"Secret Key","type":"string"},{"key":"format","label":"音频格式","type":"string"},{"key":"speed","label":"语速","type":"number"},{"key":"volume","label":"音量","type":"number"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"voice","label":"音色ID","type":"string"},{"key":"region","label":"区域","type":"string"}]'
|
||||
WHERE id = 'SYSTEM_TTS_TencentTTS';
|
||||
|
||||
-- 更新腾讯TTS模型配置,增加speed和volume参数,补充参数说明
|
||||
UPDATE `ai_model_config` SET
|
||||
`config_json` = JSON_SET(`config_json`, '$.speed', 0, '$.volume', 0),
|
||||
`remark` = '腾讯TTS配置说明:
|
||||
1. 需要在腾讯云平台开通智能语音交互服务
|
||||
2. 支持多种音色,当前配置使用101001
|
||||
3. 需要网络连接
|
||||
4. 输出文件保存在tmp/目录
|
||||
申请步骤:
|
||||
1. 访问 https://console.cloud.tencent.com/cam/capi 获取密钥
|
||||
2. 访问 https://console.cloud.tencent.com/tts/resourcebundle 领取免费资源
|
||||
3. 创建新应用
|
||||
4. 获取appid、secret_id和secret_key
|
||||
5. 填入配置文件中
|
||||
音频参数:
|
||||
- format: 音频格式,支持pcm、wav、mp3
|
||||
- speed: 语速,范围-2~6,默认0
|
||||
- volume: 音量,范围-10~10,默认0'
|
||||
WHERE `id` = 'TTS_TencentTTS';
|
||||
|
||||
-- 更新CozeCnTTS供应器配置,增加speed和loudness_rate参数
|
||||
UPDATE `ai_model_provider`
|
||||
SET fields = '[{"key":"voice","label":"音色","type":"string"},{"key":"access_token","label":"访问令牌","type":"string"},{"key":"speed","label":"语速","type":"number"},{"key":"loudness_rate","label":"音量增益","type":"number"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"response_format","label":"响应格式","type":"string"}]'
|
||||
WHERE id = 'SYSTEM_TTS_cozecn';
|
||||
|
||||
-- 更新CozeCnTTS模型配置,增加speed和loudness_rate参数,补充参数说明
|
||||
UPDATE `ai_model_config` SET
|
||||
`config_json` = JSON_SET(`config_json`, '$.speed', 1, '$.loudness_rate', 0),
|
||||
`remark` = 'Coze中文语音合成配置说明:
|
||||
1. 访问 https://www.coze.cn/ 注册并登录
|
||||
2. 创建应用并获取access_token
|
||||
3. 选择合适的音色ID
|
||||
音频参数:
|
||||
- response_format: 音频格式,支持pcm、wav、mp3
|
||||
- speed: 语速,范围0.5~2,默认1
|
||||
- loudness_rate: 音量增益,范围-50~100,默认0'
|
||||
WHERE `id` = 'TTS_CozeCnTTS';
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
-- 标签表
|
||||
CREATE TABLE IF NOT EXISTS ai_agent_tag (
|
||||
id VARCHAR(32) NOT NULL COMMENT '主键',
|
||||
tag_name VARCHAR(64) NOT NULL COMMENT '标签名称',
|
||||
sort INT UNSIGNED DEFAULT 0 COMMENT '排序',
|
||||
creator BIGINT COMMENT '创建者',
|
||||
created_at DATETIME COMMENT '创建时间',
|
||||
updater BIGINT COMMENT '更新者',
|
||||
updated_at DATETIME COMMENT '更新时间',
|
||||
deleted TINYINT DEFAULT 0 COMMENT '删除标记',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_tag_name (tag_name),
|
||||
INDEX idx_sort (sort)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='智能体标签表';
|
||||
|
||||
-- 智能体标签关联表
|
||||
CREATE TABLE IF NOT EXISTS ai_agent_tag_relation (
|
||||
id VARCHAR(32) NOT NULL COMMENT '主键',
|
||||
agent_id VARCHAR(32) NOT NULL COMMENT '智能体ID',
|
||||
tag_id VARCHAR(32) NOT NULL COMMENT '标签ID',
|
||||
creator BIGINT COMMENT '创建者',
|
||||
created_at DATETIME COMMENT '创建时间',
|
||||
updater BIGINT COMMENT '更新者',
|
||||
updated_at DATETIME COMMENT '更新时间',
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_agent_tag (agent_id, tag_id),
|
||||
INDEX idx_agent_id (agent_id),
|
||||
INDEX idx_tag_id (tag_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='智能体标签关联表';
|
||||
|
|
@ -529,3 +529,24 @@ databaseChangeLog:
|
|||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202602051125.sql
|
||||
- changeSet:
|
||||
id: 202602061650
|
||||
author: DaGou12138
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202602061650.sql
|
||||
- changeSet:
|
||||
id: 202602271137
|
||||
author: RanChen
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202602271137.sql
|
||||
- changeSet:
|
||||
id: 202602281000
|
||||
author: rainv123
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202602281000.sql
|
||||
|
|
|
|||
|
|
@ -202,3 +202,6 @@
|
|||
10193=\u8BBE\u5907ID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10194=\u8BBE\u5907\u4E0D\u5B58\u5728\u6216\u4E0D\u5728\u7EBF
|
||||
10195=OTA\u4E0A\u4F20\u6B21\u6570\u8D85\u8FC7\u9650\u5236
|
||||
10196=\u6807\u7B7E\u540D\u79F0\u5DF2\u5B58\u5728
|
||||
10197=\u6807\u7B7E\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10198=\u6807\u7B7E\u4E0D\u5B58\u5728
|
||||
|
|
@ -202,3 +202,6 @@
|
|||
10193=Adapter-ID darf nicht leer sein
|
||||
10194=Adapter nicht gefunden oder nicht online
|
||||
10195=OTA-Upload-Anzahl \u00FCberschreitet das Limit
|
||||
10196=Tag-Name existiert bereits
|
||||
10197=Tag-Name darf nicht leer sein
|
||||
10198=Tag nicht gefunden
|
||||
|
|
@ -202,3 +202,6 @@
|
|||
10193=Device ID cannot be empty
|
||||
10194=Device not found or not online
|
||||
10195=OTA upload times exceed the limit
|
||||
10196=Tag name already exists
|
||||
10197=Tag name cannot be empty
|
||||
10198=Tag not found
|
||||
|
|
@ -202,3 +202,6 @@
|
|||
10193=ID thi\u1EBFt b\u1ECB kh\u00F4ng th\u1EC3 tr\u1ED1ng
|
||||
10194=Kh\u00F4ng t\u00ECm th\u1EA5y thi\u1EBFt b\u1ECB ho\u1EB7c thi\u1EBFt b\u1ECB kh\u00F4ng tr\u1EF1c tuy\u1EBFn
|
||||
10195=S\u1ED1 l\u1EA7n t\u1EA3i l\u00EAn OTA v\u01B0\u1EE3t qu\u00E1 gi\u1EDBi h\u1EA1n
|
||||
10196=T\u00EAn th\u1EB9<42> \u0111\u00E3 t\u1ED3n t\u1EA1i
|
||||
10197=T\u00EAn th\u1EB9<42> kh\u00F4ng th\u1EC3 \u0111\u1EC3 tr\u1ED1ng
|
||||
10198=Kh\u00F4ng t\u00ECm th\u1EA5y th\u1EB9<42>
|
||||
|
|
@ -202,3 +202,6 @@
|
|||
10193=\u8A2D\u5099ID\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10194=\u8A2D\u5099\u4E0D\u5B58\u5728\u6216\u672A\u5728\u7DDA
|
||||
10195=OTA\u4E0A\u4F20\u6B21\u6578\u8D85\u904E\u9650\u5236
|
||||
10196=\u6A19\u7C64\u540D\u7A31\u5DF2\u5B58\u5728
|
||||
10197=\u6A19\u7C64\u540D\u7A31\u4E0D\u80FD\u4E3A\u7A7A
|
||||
10198=\u6A19\u7C64\u4E0D\u5B58\u5728
|
||||
|
|
@ -16,6 +16,10 @@
|
|||
<result column="llmModelId" property="llmModelId"/>
|
||||
<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"/>
|
||||
|
||||
|
|
@ -45,6 +49,10 @@
|
|||
a.vllm_model_id AS vllmModelId,
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="xiaozhi.modules.agent.dao.AgentTagDao">
|
||||
|
||||
<select id="selectByAgentId" resultType="xiaozhi.modules.agent.entity.AgentTagEntity">
|
||||
SELECT t.id, t.tag_name AS tagName, t.sort
|
||||
FROM ai_agent_tag t
|
||||
INNER JOIN ai_agent_tag_relation r ON t.id = r.tag_id
|
||||
WHERE r.agent_id = #{agentId} AND t.deleted = 0
|
||||
ORDER BY t.sort ASC
|
||||
</select>
|
||||
|
||||
<select id="selectByAgentIds" resultType="xiaozhi.modules.agent.entity.AgentTagEntity">
|
||||
SELECT t.id, t.tag_name AS tagName, t.sort, r.agent_id AS agentId
|
||||
FROM ai_agent_tag t
|
||||
INNER JOIN ai_agent_tag_relation r ON t.id = r.tag_id
|
||||
WHERE r.agent_id IN
|
||||
<foreach collection="agentIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND t.deleted = 0
|
||||
ORDER BY t.sort ASC
|
||||
</select>
|
||||
|
||||
<select id="selectAll" resultType="xiaozhi.modules.agent.entity.AgentTagEntity">
|
||||
SELECT id, tag_name AS tagName, sort
|
||||
FROM ai_agent_tag
|
||||
WHERE deleted = 0
|
||||
ORDER BY sort ASC
|
||||
</select>
|
||||
|
||||
<select id="selectAgentIdsByTagName" resultType="java.lang.String">
|
||||
SELECT r.agent_id
|
||||
FROM ai_agent_tag_relation r
|
||||
INNER JOIN ai_agent_tag t ON r.tag_id = t.id
|
||||
WHERE t.tag_name LIKE CONCAT('%', #{tagName}, '%') AND t.deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="selectByTagNames" resultType="xiaozhi.modules.agent.entity.AgentTagEntity">
|
||||
SELECT id, tag_name AS tagName, sort
|
||||
FROM ai_agent_tag
|
||||
WHERE deleted = 0 AND tag_name IN
|
||||
<foreach collection="tagNames" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO ai_agent_tag (id, tag_name, sort, deleted, creator, created_at, updater, updated_at)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id}, #{item.tagName}, #{item.sort}, #{item.deleted}, #{item.creator}, #{item.createdAt}, #{item.updater}, #{item.updatedAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="xiaozhi.modules.agent.dao.AgentTagRelationDao">
|
||||
|
||||
<delete id="deleteByAgentId">
|
||||
DELETE FROM ai_agent_tag_relation WHERE agent_id = #{agentId}
|
||||
</delete>
|
||||
|
||||
<insert id="insertRelation" parameterType="xiaozhi.modules.agent.entity.AgentTagRelationEntity">
|
||||
INSERT INTO ai_agent_tag_relation (id, agent_id, tag_id, creator, created_at, updater, updated_at)
|
||||
VALUES (#{id}, #{agentId}, #{tagId}, #{creator}, #{createdAt}, #{updater}, #{updatedAt})
|
||||
</insert>
|
||||
|
||||
<insert id="batchInsertRelation" parameterType="java.util.List">
|
||||
INSERT INTO ai_agent_tag_relation (id, agent_id, tag_id, creator, created_at, updater, updated_at)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.id}, #{item.agentId}, #{item.tagId}, #{item.creator}, #{item.createdAt}, #{item.updater}, #{item.updatedAt})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -398,4 +398,35 @@ export default {
|
|||
});
|
||||
}).send();
|
||||
},
|
||||
// 获取智能体标签
|
||||
getAgentTags(agentId, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/agent/${agentId}/tags`)
|
||||
.method('GET')
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.networkFail(() => {
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.getAgentTags(agentId, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
// 保存智能体标签
|
||||
saveAgentTags(agentId, tags, callback) {
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/agent/${agentId}/tags`)
|
||||
.method('PUT')
|
||||
.data(tags)
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
})
|
||||
.networkFail(() => {
|
||||
RequestService.reAjaxFun(() => {
|
||||
this.saveAgentTags(agentId, tags, callback);
|
||||
});
|
||||
}).send();
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<div style="color: red;display: inline-block;">*</div> {{ $t('addAgentDialog.agentName') }}:
|
||||
</div>
|
||||
<div class="input-46" style="margin-top: 12px;">
|
||||
<el-input ref="inputRef" :placeholder="$t('addAgentDialog.placeholder')" v-model="wisdomBodyName" @keyup.enter.native="confirm" />
|
||||
<el-input maxLength="64" ref="inputRef" :placeholder="$t('addAgentDialog.placeholder')" v-model="wisdomBodyName" @keyup.enter.native="confirm" />
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex;margin: 15px 15px;gap: 7px;">
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
<template>
|
||||
<div class="device-item">
|
||||
<div style="display: flex;justify-content: space-between;">
|
||||
<div style="font-weight: 700;font-size: 18px;text-align: left;color: #3d4566;">
|
||||
<el-tooltip :content="device.agentName" placement="top" effect="light">
|
||||
<div class="device-item-title">
|
||||
{{ device.agentName }}
|
||||
</div>
|
||||
</el-tooltip>
|
||||
<div>
|
||||
<img src="@/assets/home/delete.png" alt="" style="width: 18px;height: 18px;margin-right: 10px;"
|
||||
@click.stop="handleDelete" />
|
||||
<el-tooltip class="item" effect="dark" :content="device.systemPrompt" placement="top"
|
||||
<el-tooltip class="item" effect="light" :content="device.systemPrompt" placement="top"
|
||||
popper-class="custom-tooltip">
|
||||
<img src="@/assets/home/info.png" alt="" style="width: 18px;height: 18px;" />
|
||||
</el-tooltip>
|
||||
|
|
@ -39,6 +41,11 @@
|
|||
</div>
|
||||
<div class="version-info">
|
||||
<div>{{ $t('home.lastConversation') }}:{{ formattedLastConnectedTime }}</div>
|
||||
<div ref="scrollRef" class="version-info-scroll">
|
||||
<div ref="tagsRef" class="version-info-tags">
|
||||
<el-tag v-for="(tag, index) in tags" :key="index" size="mini">{{ tag }}</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -81,6 +88,10 @@ export default {
|
|||
} else {
|
||||
return this.device.lastConnectedAt;
|
||||
}
|
||||
},
|
||||
tags() {
|
||||
if (!this.device.tags) return [];
|
||||
return this.device.tags.map((tag) => tag.tagName);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -102,16 +113,45 @@ export default {
|
|||
}
|
||||
this.$emit('chat-history', { agentId: this.device.agentId, agentName: this.device.agentName })
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
tags: {
|
||||
handler(newTags) {
|
||||
if (newTags.length === 0) return;
|
||||
this.$nextTick(() => {
|
||||
const scrollWidth = this.$refs.scrollRef.clientWidth;
|
||||
const tagsWidth = this.$refs.tagsRef.clientWidth;
|
||||
if (tagsWidth < scrollWidth) {
|
||||
this.$refs.tagsRef.style.width = '100%';
|
||||
this.$refs.tagsRef.style.justifyContent = 'flex-end';
|
||||
} else {
|
||||
this.$refs.tagsRef.style.width = 'fit-content';
|
||||
this.$refs.tagsRef.style.justifyContent = 'flex-start';
|
||||
}
|
||||
})
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
<style lang="scss" scoped>
|
||||
.device-item {
|
||||
width: 342px;
|
||||
border-radius: 20px;
|
||||
background: #fafcfe;
|
||||
padding: 22px;
|
||||
padding: 22px 22px 14px;
|
||||
box-sizing: border-box;
|
||||
&-title {
|
||||
flex: 1;
|
||||
font-weight: bold;
|
||||
font-size: 18px;
|
||||
color: #3d4566;
|
||||
text-align: left;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.device-name {
|
||||
|
|
@ -142,6 +182,42 @@ export default {
|
|||
font-size: 12px;
|
||||
color: #979db1;
|
||||
font-weight: 400;
|
||||
> div {
|
||||
&:first-of-type {
|
||||
margin-top: 5px;
|
||||
}
|
||||
}
|
||||
&-scroll {
|
||||
height: 26px;
|
||||
margin-left: 20px;
|
||||
flex: 1;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 4px;
|
||||
&::-webkit-scrollbar {
|
||||
height: 6px;
|
||||
background: #e6ebff;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: #409EFF;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
&-tags {
|
||||
width: fit-content;
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.more-tag {
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.all-tags-popover {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.disabled-btn {
|
||||
|
|
|
|||
|
|
@ -879,8 +879,8 @@ export default {
|
|||
}
|
||||
|
||||
.equipment-management {
|
||||
width: 79px;
|
||||
font-size: 9px;
|
||||
min-width: 80px;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
240
main/manager-web/src/components/TtsAdvancedSettings.vue
Normal file
240
main/manager-web/src/components/TtsAdvancedSettings.vue
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
<template>
|
||||
<el-drawer
|
||||
:visible.sync="drawerVisible"
|
||||
:before-close="handleClose"
|
||||
direction="rtl"
|
||||
size="400px"
|
||||
:modal="true"
|
||||
:show-close="false"
|
||||
custom-class="tts-advanced-drawer"
|
||||
>
|
||||
<div class="drawer-header" slot="title">
|
||||
<span class="drawer-title">{{ $t('roleConfig.advancedSettings') }}</span>
|
||||
<button class="drawer-close-btn" @click="handleClose">×</button>
|
||||
</div>
|
||||
|
||||
<div class="drawer-content">
|
||||
<el-form label-position="top">
|
||||
<!-- 音量 -->
|
||||
<el-form-item :label="$t('roleConfig.ttsVolume')">
|
||||
<div class="slider-container">
|
||||
<el-slider
|
||||
v-model="localSettings.volume"
|
||||
:min="-100"
|
||||
:max="100"
|
||||
:step="1"
|
||||
:format-tooltip="formatTooltip"
|
||||
class="tts-slider"
|
||||
/>
|
||||
<span class="slider-hint">{{ $t('roleConfig.volumeHint') }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 语速 -->
|
||||
<el-form-item :label="$t('roleConfig.ttsRate')">
|
||||
<div class="slider-container">
|
||||
<el-slider
|
||||
v-model="localSettings.speed"
|
||||
:min="-100"
|
||||
:max="100"
|
||||
:step="1"
|
||||
:format-tooltip="formatTooltip"
|
||||
class="tts-slider"
|
||||
/>
|
||||
<span class="slider-hint">{{ $t('roleConfig.speedHint') }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 音调 -->
|
||||
<el-form-item :label="$t('roleConfig.ttsPitch')">
|
||||
<div class="slider-container">
|
||||
<el-slider
|
||||
v-model="localSettings.pitch"
|
||||
:min="-100"
|
||||
:max="100"
|
||||
:step="1"
|
||||
:format-tooltip="formatTooltip"
|
||||
class="tts-slider"
|
||||
/>
|
||||
<span class="slider-hint">{{ $t('roleConfig.pitchHint') }}</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div class="drawer-footer">
|
||||
<el-button @click="handleCancel">{{ $t('button.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSave">{{ $t('button.save') }}</el-button>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'TtsAdvancedSettings',
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
settings: {
|
||||
type: Object,
|
||||
default: () => ({
|
||||
volume: 0,
|
||||
speed: 0,
|
||||
pitch: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
localSettings: {
|
||||
volume: 0,
|
||||
speed: 0,
|
||||
pitch: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
drawerVisible: {
|
||||
get() {
|
||||
return this.visible;
|
||||
},
|
||||
set(val) {
|
||||
this.$emit('update:visible', val);
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(newVal) {
|
||||
if (newVal) {
|
||||
// 当抽屉打开时,复制当前设置到本地
|
||||
this.localSettings = { ...this.settings };
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClose() {
|
||||
this.$emit('update:visible', false);
|
||||
},
|
||||
handleCancel() {
|
||||
// 取消时不保存,直接关闭
|
||||
this.handleClose();
|
||||
},
|
||||
handleSave() {
|
||||
// 保存设置并关闭
|
||||
this.$emit('save', { ...this.localSettings });
|
||||
this.handleClose();
|
||||
},
|
||||
formatTooltip(val) {
|
||||
return `${val}%`;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.drawer-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 20px 24px;
|
||||
border-bottom: 1px solid #e8f0ff;
|
||||
}
|
||||
|
||||
.drawer-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #3d4566;
|
||||
}
|
||||
|
||||
.drawer-close-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid #cfcfcf;
|
||||
background: none;
|
||||
font-size: 28px;
|
||||
font-weight: lighter;
|
||||
color: #cfcfcf;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
outline: none;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.drawer-close-btn:hover {
|
||||
color: #409eff;
|
||||
border-color: #409eff;
|
||||
}
|
||||
|
||||
.drawer-content {
|
||||
padding: 24px;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.slider-container {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.slider-hint {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.tts-slider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tts-slider ::v-deep .el-slider__input {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.tts-slider ::v-deep .el-input__inner {
|
||||
text-align: center;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.drawer-footer {
|
||||
padding: 16px 24px;
|
||||
border-top: 1px solid #e8f0ff;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.drawer-footer .el-button {
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
::v-deep .el-form-item__label {
|
||||
font-size: 14px !important;
|
||||
color: #3d4566 !important;
|
||||
font-weight: 500;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
::v-deep .el-form-item {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
||||
.tts-advanced-drawer .el-drawer__header {
|
||||
margin-bottom: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.tts-advanced-drawer .el-drawer__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -71,8 +71,14 @@
|
|||
{{ $t('ttsModel.delete') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<el-button v-else type="success" size="mini" @click="saveEdit(scope.row)" class="save-Tts">{{ $t('ttsModel.save') }}
|
||||
<template v-else>
|
||||
<el-button type="success" size="mini" @click="cancelEdit(scope.row)" class="save-Tts">
|
||||
{{ $t('button.cancel') }}
|
||||
</el-button>
|
||||
<el-button type="success" size="mini" @click="saveEdit(scope.row)" class="save-Tts">
|
||||
{{ $t('ttsModel.save') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
|
@ -340,6 +346,17 @@ export default {
|
|||
this.$set(row, 'originalData', { ...row });
|
||||
},
|
||||
|
||||
cancelEdit(row) {
|
||||
// 通过新增创建的数据,取消编辑时,需要从数组中移除
|
||||
if (!row.id) {
|
||||
this.ttsModels.shift(row);
|
||||
} else {
|
||||
Object.assign(row, row.originalData);
|
||||
delete row.originalData;
|
||||
}
|
||||
row.editing = false;
|
||||
},
|
||||
|
||||
saveEdit(row) {
|
||||
if (!row.voiceCode || !row.voiceName || !row.languageType) {
|
||||
this.$message.error({
|
||||
|
|
@ -447,7 +464,7 @@ export default {
|
|||
referenceText: '',
|
||||
selected: false,
|
||||
editing: true,
|
||||
sort: maxSort + 1
|
||||
sort: 0 // 新增数据默认排序在顶部
|
||||
};
|
||||
|
||||
this.ttsModels.unshift(newRow);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export default {
|
|||
'header.featureManagement': 'Systemfunktionsverwaltung',
|
||||
'header.changePassword': 'Passwort ändern',
|
||||
'header.logout': 'Abmelden',
|
||||
'header.searchPlaceholder': 'Namen oder MAC suchen',
|
||||
'header.searchPlaceholder': 'Name, Tag oder Mac-Suche',
|
||||
|
||||
// McpToolCallDialog component text
|
||||
'mcpToolCall.title': 'Werkzeugaufruf',
|
||||
|
|
@ -747,6 +747,7 @@ export default {
|
|||
|
||||
// Role configuration page text
|
||||
'roleConfig.title': 'Rollenkonfiguration',
|
||||
'roleConfig.addTag': 'Neues Label hinzufügen',
|
||||
'roleConfig.restartNotice': 'Nach dem Speichern der Konfiguration müssen Sie das Gerät neu starten, damit die neue Konfiguration wirksam wird.',
|
||||
'roleConfig.saveConfig': 'Konfiguration speichern',
|
||||
'roleConfig.reset': 'Zurücksetzen',
|
||||
|
|
@ -763,7 +764,16 @@ export default {
|
|||
'roleConfig.memoryHis': 'Speicher',
|
||||
'roleConfig.memory': 'Speicher',
|
||||
'roleConfig.intent': 'Intent',
|
||||
'roleConfig.language': 'Sprache auswählen',
|
||||
'roleConfig.voiceType': 'Stimmtyp',
|
||||
'roleConfig.ttsVolume': 'Lautstärke',
|
||||
'roleConfig.ttsRate': 'Geschwindigkeit',
|
||||
'roleConfig.ttsPitch': 'Tonhöhe',
|
||||
'roleConfig.ttsAdvanced': 'TTS-Parameter',
|
||||
'roleConfig.advancedSettings': 'Erweiterte Einstellungen',
|
||||
'roleConfig.volumeHint': '-100=Min, 0=Standard, 100=Max',
|
||||
'roleConfig.speedHint': '-100=Langsamste, 0=Standard, 100=Schnellste',
|
||||
'roleConfig.pitchHint': '-100=Niedrigste, 0=Standard, 100=Höchste',
|
||||
'roleConfig.pleaseEnterContent': 'Bitte Inhalt eingeben',
|
||||
'roleConfig.pleaseEnterLangCode': 'Bitte Sprachcode eingeben, z.B.: en_US',
|
||||
'roleConfig.pleaseEnterLangName': 'Bitte Interaktionssprache eingeben, z.B.: Englisch',
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export default {
|
|||
'header.featureManagement': 'System Feature Management',
|
||||
'header.changePassword': 'Change Password',
|
||||
'header.logout': 'Logout',
|
||||
'header.searchPlaceholder': 'Search name or mac',
|
||||
'header.searchPlaceholder': 'Name, tag or MAC search',
|
||||
|
||||
// McpToolCallDialog component text
|
||||
'mcpToolCall.title': 'Tool Call',
|
||||
|
|
@ -747,6 +747,7 @@ export default {
|
|||
|
||||
// Role configuration page text
|
||||
'roleConfig.title': 'Role Configuration',
|
||||
'roleConfig.addTag': 'Add New Tag',
|
||||
'roleConfig.restartNotice': 'After saving the configuration, you need to restart the device for the new configuration to take effect.',
|
||||
'roleConfig.saveConfig': 'Save Configuration',
|
||||
'roleConfig.reset': 'Reset',
|
||||
|
|
@ -763,7 +764,16 @@ export default {
|
|||
'roleConfig.memoryHis': 'Memory',
|
||||
'roleConfig.memory': 'Memory Model',
|
||||
'roleConfig.intent': 'Intent Recognition',
|
||||
'roleConfig.language': 'Select Language',
|
||||
'roleConfig.voiceType': 'Voice Type',
|
||||
'roleConfig.ttsVolume': 'Volume',
|
||||
'roleConfig.ttsRate': 'Speed',
|
||||
'roleConfig.ttsPitch': 'Pitch',
|
||||
'roleConfig.ttsAdvanced': 'TTS Parameters',
|
||||
'roleConfig.advancedSettings': 'Advanced Settings',
|
||||
'roleConfig.volumeHint': '-100=Min, 0=Standard, 100=Max',
|
||||
'roleConfig.speedHint': '-100=Slowest, 0=Standard, 100=Fastest',
|
||||
'roleConfig.pitchHint': '-100=Lowest, 0=Standard, 100=Highest',
|
||||
'roleConfig.pleaseEnterContent': 'Please enter content',
|
||||
'roleConfig.pleaseEnterLangCode': 'Please enter language code, e.g.: en_US',
|
||||
'roleConfig.pleaseEnterLangName': 'Please enter interaction language, e.g.: English',
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export default {
|
|||
'header.featureManagement': 'Gerenciamento de Funcionalidades do Sistema',
|
||||
'header.changePassword': 'Alterar Senha',
|
||||
'header.logout': 'Sair',
|
||||
'header.searchPlaceholder': 'Pesquisar nome ou MAC',
|
||||
'header.searchPlaceholder': 'Nome, tag ou pesquisa no Mac',
|
||||
|
||||
// Texto do componente McpToolCallDialog
|
||||
'mcpToolCall.title': 'Chamada de Ferramenta',
|
||||
|
|
@ -747,6 +747,7 @@ export default {
|
|||
|
||||
// Página de configuração de papel
|
||||
'roleConfig.title': 'Configuração de Papel',
|
||||
'roleConfig.addTag': 'Adicionar Novo Rótulo',
|
||||
'roleConfig.restartNotice': 'Após salvar a configuração, é necessário reiniciar o dispositivo para que a nova configuração tenha efeito.',
|
||||
'roleConfig.saveConfig': 'Salvar Configuração',
|
||||
'roleConfig.reset': 'Redefinir',
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export default {
|
|||
'header.featureManagement': 'Cấu hình chức năng hệ thống',
|
||||
'header.changePassword': 'Đổi mật khẩu',
|
||||
'header.logout': 'Đăng xuất',
|
||||
'header.searchPlaceholder': 'Tìm tên hoặc MAC',
|
||||
'header.searchPlaceholder': 'Tên, thẻ hoặc tìm kiếm mac',
|
||||
|
||||
// McpToolCallDialog component text
|
||||
'mcpToolCall.title': 'Gọi công cụ',
|
||||
|
|
@ -747,6 +747,7 @@ export default {
|
|||
|
||||
// Role configuration page text
|
||||
'roleConfig.title': 'Vai trò',
|
||||
'roleConfig.addTag': 'Thêm mới nhãn',
|
||||
'roleConfig.restartNotice': 'Sau khi lưu cấu hình, bạn cần khởi động lại thiết bị để cấu hình mới có hiệu lực.',
|
||||
'roleConfig.saveConfig': 'Lưu cấu hình',
|
||||
'roleConfig.reset': 'Đặt lại',
|
||||
|
|
@ -763,7 +764,16 @@ export default {
|
|||
'roleConfig.memoryHis': 'Bộ nhớ',
|
||||
'roleConfig.memory': 'Mô hình bộ nhớ',
|
||||
'roleConfig.intent': 'Nhận dạng ý định',
|
||||
'roleConfig.language': 'Chọn ngôn ngữ',
|
||||
'roleConfig.voiceType': 'Loại giọng nói',
|
||||
'roleConfig.ttsVolume': 'Âm lượng',
|
||||
'roleConfig.ttsRate': 'Tốc độ',
|
||||
'roleConfig.ttsPitch': 'Cao độ',
|
||||
'roleConfig.ttsAdvanced': 'Tham số TTS',
|
||||
'roleConfig.advancedSettings': 'Cài đặt nâng cao',
|
||||
'roleConfig.volumeHint': '-100=Tối thiểu, 0=Tiêu chuẩn, 100=Tối đa',
|
||||
'roleConfig.speedHint': '-100=Chậm nhất, 0=Tiêu chuẩn, 100=Nhanh nhất',
|
||||
'roleConfig.pitchHint': '-100=Thấp nhất, 0=Tiêu chuẩn, 100=Cao nhất',
|
||||
'roleConfig.pleaseEnterContent': 'Vui lòng nhập nội dung',
|
||||
'roleConfig.pleaseEnterLangCode': 'Vui lòng nhập mã ngôn ngữ, ví dụ: en_US',
|
||||
'roleConfig.pleaseEnterLangName': 'Vui lòng nhập ngôn ngữ tương tác, ví dụ: Tiếng Anh',
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export default {
|
|||
'header.featureManagement': '系统功能配置',
|
||||
'header.changePassword': '修改密码',
|
||||
'header.logout': '退出登录',
|
||||
'header.searchPlaceholder': '输入名称或mac搜索',
|
||||
'header.searchPlaceholder': '名称、标签或mac搜索',
|
||||
|
||||
// McpToolCallDialog组件文本
|
||||
'mcpToolCall.title': '工具调用',
|
||||
|
|
@ -747,6 +747,7 @@ export default {
|
|||
|
||||
// 角色配置页面文本
|
||||
'roleConfig.title': '角色配置',
|
||||
'roleConfig.addTag': '添加新标签',
|
||||
'roleConfig.restartNotice': '保存配置后,需要重启设备,新的配置才会生效。',
|
||||
'roleConfig.saveConfig': '保存配置',
|
||||
'roleConfig.reset': '重置',
|
||||
|
|
@ -763,7 +764,16 @@ export default {
|
|||
'roleConfig.memoryHis': '记忆',
|
||||
'roleConfig.memory': '记忆模式',
|
||||
'roleConfig.tts': '语音合成(TTS)',
|
||||
'roleConfig.language': '选择语言',
|
||||
'roleConfig.voiceType': '声音音色(Voice)',
|
||||
'roleConfig.ttsVolume': '音量',
|
||||
'roleConfig.ttsRate': '语速',
|
||||
'roleConfig.ttsPitch': '音调',
|
||||
'roleConfig.ttsAdvanced': 'TTS参数',
|
||||
'roleConfig.advancedSettings': '高级设置',
|
||||
'roleConfig.volumeHint': '-100=最小, 0=标准, 100=最大',
|
||||
'roleConfig.speedHint': '-100=最慢, 0=标准, 100=最快',
|
||||
'roleConfig.pitchHint': '-100=最低, 0=标准, 100=最高',
|
||||
'roleConfig.pleaseEnterContent': '请输入内容',
|
||||
'roleConfig.pleaseEnterLangCode': '请输入语言编码,如:zh_CN',
|
||||
'roleConfig.pleaseEnterLangName': '请输入交互语种,如:中文',
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export default {
|
|||
'header.featureManagement': '系統功能配置',
|
||||
'header.changePassword': '修改密碼',
|
||||
'header.logout': '退出登錄',
|
||||
'header.searchPlaceholder': '輸入名稱或mac搜索',
|
||||
'header.searchPlaceholder': '名稱、標籤或mac搜索',
|
||||
|
||||
// McpToolCallDialog组件文本
|
||||
'mcpToolCall.title': '工具調用',
|
||||
|
|
@ -747,6 +747,7 @@ export default {
|
|||
|
||||
// 角色配置頁面文本
|
||||
'roleConfig.title': '角色配置',
|
||||
'roleConfig.addTag': '添加新標籤',
|
||||
'roleConfig.restartNotice': '保存配置後,需要重啟設備,新的配置才會生效。',
|
||||
'roleConfig.saveConfig': '保存配置',
|
||||
'roleConfig.reset': '重置',
|
||||
|
|
@ -763,7 +764,16 @@ export default {
|
|||
'roleConfig.memoryHis': '記憶',
|
||||
'roleConfig.memory': '記憶模式',
|
||||
'roleConfig.intent': '意圖識別(Intent)',
|
||||
'roleConfig.language': '選擇語言',
|
||||
'roleConfig.voiceType': '聲音音色(Voice)',
|
||||
'roleConfig.ttsVolume': '音量',
|
||||
'roleConfig.ttsRate': '語速',
|
||||
'roleConfig.ttsPitch': '音調',
|
||||
'roleConfig.ttsAdvanced': 'TTS參數',
|
||||
'roleConfig.advancedSettings': '高級設置',
|
||||
'roleConfig.volumeHint': '-100=最小, 0=標準, 100=最大',
|
||||
'roleConfig.speedHint': '-100=最慢, 0=標準, 100=最快',
|
||||
'roleConfig.pitchHint': '-100=最低, 0=標準, 100=最高',
|
||||
'roleConfig.pleaseEnterContent': '請輸入內容',
|
||||
'roleConfig.pleaseEnterLangCode': '請輸入語言編碼,如:zh_TW',
|
||||
'roleConfig.pleaseEnterLangName': '請輸入交互語種,如:繁體中文',
|
||||
|
|
|
|||
|
|
@ -20,3 +20,13 @@ select:-webkit-autofill:focus {
|
|||
.el-icon-video-play, .el-icon-video-pause {
|
||||
font-size: 18px !important;
|
||||
}
|
||||
|
||||
.is-light {
|
||||
border: 1px solid #e4e7ed !important;
|
||||
color: #595959;
|
||||
font-size: 14px;
|
||||
background: #fafcfe !important;
|
||||
.popper__arrow {
|
||||
border-top-color: #e4e7ed !important;
|
||||
}
|
||||
}
|
||||
|
|
@ -11,10 +11,34 @@
|
|||
<div class="content-area">
|
||||
<el-card class="config-card" shadow="never">
|
||||
<div class="config-header">
|
||||
<div class="header-icon">
|
||||
<img loading="lazy" src="@/assets/home/setting-user.png" alt="" />
|
||||
<div class="header-left">
|
||||
<div class="header-icon">
|
||||
<img loading="lazy" src="@/assets/home/setting-user.png" alt="" />
|
||||
</div>
|
||||
<span class="header-title">{{ form.agentName }}</span>
|
||||
</div>
|
||||
<div class="header-tags">
|
||||
<el-tag
|
||||
v-for="tag in dynamicTags"
|
||||
:key="tag.id"
|
||||
closable
|
||||
:disable-transitions="false"
|
||||
@close="handleClose(tag.id)">
|
||||
{{tag.tagName}}
|
||||
</el-tag>
|
||||
<el-input
|
||||
class="input-new-tag"
|
||||
v-if="inputVisible"
|
||||
v-model="inputValue"
|
||||
ref="saveTagInput"
|
||||
size="small"
|
||||
maxLength="64"
|
||||
@keyup.enter.native="handleInputConfirm"
|
||||
@blur="handleInputConfirm"
|
||||
>
|
||||
</el-input>
|
||||
<el-button v-else size="small" @click="showInput">+ {{ $t("roleConfig.addTag") }}</el-button>
|
||||
</div>
|
||||
<span class="header-title">{{ form.agentName }}</span>
|
||||
<div class="header-actions">
|
||||
<div class="hint-text">
|
||||
<img loading="lazy" src="@/assets/home/info.png" alt="" />
|
||||
|
|
@ -39,7 +63,7 @@
|
|||
<el-input
|
||||
v-model="form.agentName"
|
||||
class="form-input"
|
||||
maxlength="10"
|
||||
maxlength="64"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('roleConfig.roleTemplate') + ':'">
|
||||
|
|
@ -232,47 +256,78 @@
|
|||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('roleConfig.voiceType')">
|
||||
<el-select
|
||||
v-model="form.ttsVoiceId"
|
||||
filterable
|
||||
:placeholder="$t('roleConfig.pleaseSelect')"
|
||||
class="form-select"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in voiceOptions"
|
||||
:key="`voice-${index}`"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
>
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
"
|
||||
<div class="model-row">
|
||||
<!-- 语言筛选器 -->
|
||||
<el-form-item :label="$t('roleConfig.language')" class="model-item language-select-item">
|
||||
<div class="model-select-wrapper">
|
||||
<el-select
|
||||
v-model="selectedLanguage"
|
||||
:placeholder="$t('roleConfig.selectLanguage')"
|
||||
class="form-select language-select"
|
||||
@change="filterVoicesByLanguage"
|
||||
>
|
||||
<span>{{ item.label }}</span>
|
||||
<template v-if="hasAudioPreview(item)">
|
||||
<el-button
|
||||
type="text"
|
||||
:icon="
|
||||
playingVoice &&
|
||||
currentPlayingVoiceId === item.value &&
|
||||
!isPaused
|
||||
? 'el-icon-video-pause'
|
||||
: 'el-icon-video-play'
|
||||
<el-option
|
||||
v-for="(lang, index) in languageOptions"
|
||||
:key="`lang-${index}`"
|
||||
:label="lang.label"
|
||||
:value="lang.value"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<!-- 音色选择器 -->
|
||||
<el-form-item :label="$t('roleConfig.voiceType')" class="model-item">
|
||||
<div class="model-select-wrapper">
|
||||
<el-select
|
||||
v-model="form.ttsVoiceId"
|
||||
filterable
|
||||
:placeholder="$t('roleConfig.pleaseSelect')"
|
||||
class="form-select"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in voiceOptions"
|
||||
:key="`voice-${index}`"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
>
|
||||
<div
|
||||
style="
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
"
|
||||
size="small"
|
||||
@click.stop="toggleAudioPlayback(item.value)"
|
||||
:loading="false"
|
||||
class="play-button"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
>
|
||||
<span>{{ item.label }}</span>
|
||||
<template v-if="hasAudioPreview(item)">
|
||||
<el-button
|
||||
type="text"
|
||||
:icon="
|
||||
playingVoice &&
|
||||
currentPlayingVoiceId === item.value &&
|
||||
!isPaused
|
||||
? 'el-icon-video-pause'
|
||||
: 'el-icon-video-play'
|
||||
"
|
||||
size="small"
|
||||
@click.stop="toggleAudioPlayback(item.value)"
|
||||
:loading="false"
|
||||
class="play-button"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
<el-button
|
||||
class="edit-function-btn"
|
||||
style="margin-left: 10px;"
|
||||
@click="openTtsAdvancedSettings"
|
||||
>
|
||||
{{ $t('roleConfig.advancedSettings') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -294,6 +349,11 @@
|
|||
:providers="currentContextProviders"
|
||||
@confirm="handleUpdateContext"
|
||||
/>
|
||||
<tts-advanced-settings
|
||||
:visible.sync="showTtsAdvancedDialog"
|
||||
:settings="ttsSettings"
|
||||
@save="handleTtsSettingsSave"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -303,20 +363,30 @@ import { getServiceUrl } from "@/apis/api";
|
|||
import RequestService from "@/apis/httpRequest";
|
||||
import FunctionDialog from "@/components/FunctionDialog.vue";
|
||||
import ContextProviderDialog from "@/components/ContextProviderDialog.vue";
|
||||
import TtsAdvancedSettings from "@/components/TtsAdvancedSettings.vue";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import i18n from "@/i18n";
|
||||
import featureManager from "@/utils/featureManager";
|
||||
|
||||
export default {
|
||||
name: "RoleConfigPage",
|
||||
components: { HeaderBar, FunctionDialog, ContextProviderDialog },
|
||||
components: { HeaderBar, FunctionDialog, ContextProviderDialog, TtsAdvancedSettings },
|
||||
data() {
|
||||
return {
|
||||
showContextProviderDialog: false,
|
||||
showTtsAdvancedDialog: false,
|
||||
ttsSettings: {
|
||||
volume: 0,
|
||||
speed: 0,
|
||||
pitch: 0
|
||||
},
|
||||
form: {
|
||||
agentCode: "",
|
||||
agentName: "",
|
||||
ttsVoiceId: "",
|
||||
ttsVolume: null,
|
||||
ttsRate: null,
|
||||
ttsPitch: null,
|
||||
chatHistoryConf: 0,
|
||||
systemPrompt: "",
|
||||
summaryMemory: "",
|
||||
|
|
@ -357,18 +427,31 @@ export default {
|
|||
isPaused: false,
|
||||
currentAudio: null,
|
||||
currentPlayingVoiceId: null,
|
||||
// 语言筛选相关状态
|
||||
languageOptions: [], // 语言选项列表
|
||||
selectedLanguage: '', // 当前选中的语言
|
||||
// 功能状态
|
||||
featureStatus: {
|
||||
vad: false, // 语言检测活动功能状态
|
||||
asr: false, // 语音识别功能状态
|
||||
},
|
||||
dynamicTags: [],
|
||||
inputVisible: false,
|
||||
inputValue: ''
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
goToHome() {
|
||||
this.$router.push("/home");
|
||||
},
|
||||
saveConfig() {
|
||||
async saveConfig() {
|
||||
try {
|
||||
await this.handleSaveAgentTags(this.$route.query.agentId);
|
||||
} catch (error) {
|
||||
console.error('保存标签失败:', error);
|
||||
return;
|
||||
}
|
||||
|
||||
const configData = {
|
||||
agentCode: this.form.agentCode,
|
||||
agentName: this.form.agentName,
|
||||
|
|
@ -378,6 +461,7 @@ export default {
|
|||
vllmModelId: this.form.model.vllmModelId,
|
||||
ttsModelId: this.form.model.ttsModelId,
|
||||
ttsVoiceId: this.form.ttsVoiceId,
|
||||
ttsLanguage: this.selectedLanguage,
|
||||
chatHistoryConf: this.form.chatHistoryConf,
|
||||
memModelId: this.form.model.memModelId,
|
||||
intentModelId: this.form.model.intentModelId,
|
||||
|
|
@ -394,6 +478,17 @@ export default {
|
|||
}),
|
||||
contextProviders: this.currentContextProviders,
|
||||
};
|
||||
|
||||
// 只在用户设置了TTS参数时才传递(不为null/undefined)
|
||||
if (this.form.ttsVolume !== null && this.form.ttsVolume !== undefined) {
|
||||
configData.ttsVolume = this.form.ttsVolume;
|
||||
}
|
||||
if (this.form.ttsRate !== null && this.form.ttsRate !== undefined) {
|
||||
configData.ttsRate = this.form.ttsRate;
|
||||
}
|
||||
if (this.form.ttsPitch !== null && this.form.ttsPitch !== undefined) {
|
||||
configData.ttsPitch = this.form.ttsPitch;
|
||||
}
|
||||
Api.agent.updateAgentConfig(this.$route.query.agentId, configData, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.$message.success({
|
||||
|
|
@ -407,6 +502,7 @@ export default {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
resetConfig() {
|
||||
this.$confirm(i18n.t("roleConfig.confirmReset"), i18n.t("message.info"), {
|
||||
|
|
@ -435,6 +531,7 @@ export default {
|
|||
intentModelId: "",
|
||||
},
|
||||
};
|
||||
this.dynamicTags = [];
|
||||
this.currentFunctions = [];
|
||||
this.$message.success({
|
||||
message: i18n.t("roleConfig.resetSuccess"),
|
||||
|
|
@ -507,6 +604,14 @@ export default {
|
|||
intentModelId: data.data.intentModelId,
|
||||
},
|
||||
};
|
||||
|
||||
// 同步TTS设置到ttsSettings
|
||||
this.ttsSettings = {
|
||||
volume: this.form.ttsVolume || 0,
|
||||
speed: this.form.ttsRate || 0,
|
||||
pitch: this.form.ttsPitch || 0
|
||||
};
|
||||
|
||||
// 后端只给了最小映射:[{ id, agentId, pluginId }, ...]
|
||||
const savedMappings = data.data.functions || [];
|
||||
|
||||
|
|
@ -592,32 +697,91 @@ export default {
|
|||
if (!modelId) {
|
||||
this.voiceOptions = [];
|
||||
this.voiceDetails = {};
|
||||
this.languageOptions = [];
|
||||
this.selectedLanguage = '';
|
||||
return;
|
||||
}
|
||||
Api.model.getModelVoices(modelId, "", ({ data }) => {
|
||||
if (data.code === 0 && data.data) {
|
||||
this.voiceOptions = data.data.map((voice) => ({
|
||||
value: voice.id,
|
||||
label: voice.name,
|
||||
// 只保留后端实际返回的音频相关字段
|
||||
voiceDemo: voice.voiceDemo,
|
||||
voice_demo: voice.voice_demo,
|
||||
// 使用后端实际返回的 isClone 字段
|
||||
isClone: Boolean(voice.isClone),
|
||||
// 保存训练状态字段
|
||||
train_status: voice.trainStatus,
|
||||
}));
|
||||
// 保存完整的音色信息,添加调试信息
|
||||
// 保存完整的音色信息
|
||||
this.voiceDetails = data.data.reduce((acc, voice) => {
|
||||
acc[voice.id] = voice;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// 提取所有语言选项并去重
|
||||
const allLanguages = new Set();
|
||||
data.data.forEach(voice => {
|
||||
if (voice.languages) {
|
||||
const languagesArray = voice.languages.split('、').map(lang => lang.trim()).filter(lang => lang);
|
||||
languagesArray.forEach(lang => allLanguages.add(lang));
|
||||
}
|
||||
});
|
||||
|
||||
this.languageOptions = Array.from(allLanguages).map(lang => ({
|
||||
value: lang,
|
||||
label: lang
|
||||
}));
|
||||
|
||||
// 使用后端返回的用户选择的语言,如果没有则使用第一个语言选项
|
||||
if (this.form.ttsLanguage && this.languageOptions.some(option => option.value === this.form.ttsLanguage)) {
|
||||
this.selectedLanguage = this.form.ttsLanguage;
|
||||
} else if (this.languageOptions.length > 0) {
|
||||
this.selectedLanguage = this.languageOptions[0].value;
|
||||
}
|
||||
|
||||
// 根据选中的语言筛选音色
|
||||
this.filterVoicesByLanguage();
|
||||
} else {
|
||||
this.voiceOptions = [];
|
||||
this.voiceDetails = {};
|
||||
this.languageOptions = [];
|
||||
this.selectedLanguage = '';
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 根据语言筛选音色
|
||||
filterVoicesByLanguage() {
|
||||
if (!this.voiceDetails || Object.keys(this.voiceDetails).length === 0) {
|
||||
this.voiceOptions = [];
|
||||
return;
|
||||
}
|
||||
|
||||
const allVoices = Object.values(this.voiceDetails);
|
||||
|
||||
// 根据选中的语言筛选音色
|
||||
const filteredVoices = allVoices.filter(voice => {
|
||||
if (!voice.languages) return false;
|
||||
const languagesArray = voice.languages.split('、').map(lang => lang.trim()).filter(lang => lang);
|
||||
return languagesArray.includes(this.selectedLanguage);
|
||||
});
|
||||
|
||||
this.voiceOptions = filteredVoices.map((voice) => ({
|
||||
value: voice.id,
|
||||
label: voice.name,
|
||||
voiceDemo: voice.voiceDemo,
|
||||
voice_demo: voice.voice_demo,
|
||||
isClone: Boolean(voice.isClone),
|
||||
train_status: voice.trainStatus,
|
||||
}));
|
||||
|
||||
// 检查当前选中的音色是否支持当前语言,如果不支持则选择第一个
|
||||
const currentVoiceSupportsLanguage = this.form.ttsVoiceId &&
|
||||
filteredVoices.some(voice => voice.id === this.form.ttsVoiceId);
|
||||
|
||||
if (!currentVoiceSupportsLanguage) {
|
||||
this.form.ttsVoiceId = filteredVoices.length > 0 ? filteredVoices[0].id : '';
|
||||
}
|
||||
|
||||
// 同步到ttsSettings(如果值为null,使用0作为显示默认值,但不修改form中的值)
|
||||
this.ttsSettings = {
|
||||
volume: this.form.ttsVolume !== null && this.form.ttsVolume !== undefined ? this.form.ttsVolume : 0,
|
||||
speed: this.form.ttsRate !== null && this.form.ttsRate !== undefined ? this.form.ttsRate : 0,
|
||||
pitch: this.form.ttsPitch !== null && this.form.ttsPitch !== undefined ? this.form.ttsPitch : 0
|
||||
};
|
||||
},
|
||||
|
||||
getFunctionDisplayChar(name) {
|
||||
if (!name || name.length === 0) return "";
|
||||
|
||||
|
|
@ -683,6 +847,16 @@ export default {
|
|||
openContextProviderDialog() {
|
||||
this.showContextProviderDialog = true;
|
||||
},
|
||||
openTtsAdvancedSettings() {
|
||||
this.showTtsAdvancedDialog = true;
|
||||
},
|
||||
handleTtsSettingsSave(settings) {
|
||||
// 保存TTS设置
|
||||
this.ttsSettings = { ...settings };
|
||||
this.form.ttsVolume = settings.volume;
|
||||
this.form.ttsRate = settings.speed;
|
||||
this.form.ttsPitch = settings.pitch;
|
||||
},
|
||||
handleUpdateContext(providers) {
|
||||
this.currentContextProviders = providers;
|
||||
},
|
||||
|
|
@ -1010,6 +1184,45 @@ export default {
|
|||
console.error("加载功能状态失败:", error);
|
||||
}
|
||||
},
|
||||
handleClose(id) {
|
||||
this.dynamicTags = this.dynamicTags.filter((item) => item.id !== id);
|
||||
},
|
||||
|
||||
showInput() {
|
||||
this.inputVisible = true;
|
||||
this.$nextTick(_ => {
|
||||
this.$refs.saveTagInput.$refs.input.focus();
|
||||
});
|
||||
},
|
||||
|
||||
handleInputConfirm() {
|
||||
let inputValue = this.inputValue;
|
||||
if (inputValue) {
|
||||
const tag = { id: new Date().getTime(), tagName: inputValue };
|
||||
this.dynamicTags.push(tag);
|
||||
}
|
||||
this.inputVisible = false;
|
||||
this.inputValue = '';
|
||||
},
|
||||
getAgentTags(agentId) {
|
||||
Api.agent.getAgentTags(agentId, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.dynamicTags = data.data || [];
|
||||
}
|
||||
});
|
||||
},
|
||||
handleSaveAgentTags(agentId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const tagNames = this.dynamicTags.map(tag => tag.tagName);
|
||||
Api.agent.saveAgentTags(agentId, { tagNames }, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(data.msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
"form.model.ttsModelId": {
|
||||
|
|
@ -1036,6 +1249,7 @@ export default {
|
|||
const agentId = this.$route.query.agentId;
|
||||
if (agentId) {
|
||||
this.fetchAgentConfig(agentId);
|
||||
this.getAgentTags(agentId);
|
||||
this.fetchAllFunctions();
|
||||
}
|
||||
this.fetchModelOptions();
|
||||
|
|
@ -1046,7 +1260,7 @@ export default {
|
|||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
<style lang="scss" scoped>
|
||||
.welcome {
|
||||
min-width: 900px;
|
||||
height: 100vh;
|
||||
|
|
@ -1123,6 +1337,48 @@ export default {
|
|||
font-weight: 700;
|
||||
font-size: 19px;
|
||||
color: #3d4566;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.header-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 13px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.header-tags {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 4px;
|
||||
&::-webkit-scrollbar {
|
||||
height: 6px;
|
||||
background: #e6ebff;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: #409EFF;
|
||||
border-radius: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.header-tags .el-tag {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.more-tag {
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.all-tags-popover {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.header-icon {
|
||||
|
|
@ -1236,6 +1492,15 @@ export default {
|
|||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.model-row .language-select-item {
|
||||
flex: 0 0 35%;
|
||||
max-width: 35%;
|
||||
}
|
||||
|
||||
.model-row .language-select-item .language-select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.model-row .el-form-item__label {
|
||||
font-size: 12px !important;
|
||||
color: #3d4566 !important;
|
||||
|
|
@ -1411,4 +1676,36 @@ export default {
|
|||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
.slider-wrapper {
|
||||
width: 100%;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
.slider-hint {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-top: 4px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.tts-slider {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tts-slider ::v-deep .el-slider__input {
|
||||
width: 80px;
|
||||
}
|
||||
|
||||
.tts-slider ::v-deep .el-input__inner {
|
||||
text-align: center;
|
||||
padding: 0 8px;
|
||||
}
|
||||
.input-new-tag {
|
||||
width: 90px;
|
||||
&::v-deep(.el-input__inner) {
|
||||
width: 90px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
{{base_prompt}}
|
||||
</identity>
|
||||
|
||||
<language>
|
||||
【语言规范】你必须使用{{language}}进行回复和交流。无论用户使用何种语言提问,你都应该用{{language}}来回答。
|
||||
</language>
|
||||
|
||||
<emotion>
|
||||
【核心目标】你不是冰冷的机器!请敏锐感知用户情绪,作为懂人心的伙伴,用有温度的回应照亮对话。
|
||||
- **情感融入:**
|
||||
|
|
|
|||
|
|
@ -733,6 +733,7 @@ TTS:
|
|||
type: edge
|
||||
voice: zh-CN-XiaoxiaoNeural
|
||||
output_dir: tmp/
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
DoubaoTTS:
|
||||
# 定义TTS API类型
|
||||
type: doubao
|
||||
|
|
@ -751,6 +752,7 @@ TTS:
|
|||
speed_ratio: 1.0
|
||||
volume_ratio: 1.0
|
||||
pitch_ratio: 1.0
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
#火山tts,支持双向流式tts
|
||||
HuoshanDoubleStreamTTS:
|
||||
type: huoshan_double_stream
|
||||
|
|
@ -791,6 +793,7 @@ TTS:
|
|||
# mix_factor: 0.3
|
||||
# - source_speaker: zh_male_ahu_conversation_wvae_bigtts
|
||||
# mix_factor: 0.4
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
CosyVoiceSiliconflow:
|
||||
type: siliconflow
|
||||
# 硅基流动TTS
|
||||
|
|
@ -800,6 +803,7 @@ TTS:
|
|||
output_dir: tmp/
|
||||
access_token: 你的硅基流动API密钥
|
||||
response_format: wav
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
CozeCnTTS:
|
||||
type: cozecn
|
||||
# COZECN TTS
|
||||
|
|
@ -808,6 +812,10 @@ TTS:
|
|||
output_dir: tmp/
|
||||
access_token: 你的coze web key
|
||||
response_format: wav
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
# 以下可不用设置,使用默认设置
|
||||
# speed: 1 # 语速:-0.5到2
|
||||
# loudness_rate: 0 # 音量:-50到100
|
||||
VolcesAiGatewayTTS:
|
||||
type: openai
|
||||
# 火山引擎 - 边缘大模型网关
|
||||
|
|
@ -822,6 +830,7 @@ TTS:
|
|||
voice: zh_male_shaonianzixin_moon_bigtts
|
||||
speed: 1
|
||||
output_dir: tmp/
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
FishSpeech:
|
||||
# 参照教程:https://github.com/xinnan-tech/xiaozhi-esp32-server/blob/main/docs/fish-speech-integration.md
|
||||
type: fishspeech
|
||||
|
|
@ -843,6 +852,7 @@ TTS:
|
|||
rate: 44100
|
||||
api_key: "你的api_key"
|
||||
api_url: "http://127.0.0.1:8080/v1/tts"
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
GPT_SOVITS_V2:
|
||||
# 定义TTS API类型
|
||||
#启动tts方法:
|
||||
|
|
@ -868,6 +878,7 @@ TTS:
|
|||
parallel_infer: true
|
||||
repetition_penalty: 1.35
|
||||
aux_ref_audio_paths: []
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
GPT_SOVITS_V3:
|
||||
# 定义TTS API类型 GPT-SoVITS-v3lora-20250228
|
||||
#启动tts方法:
|
||||
|
|
@ -887,6 +898,7 @@ TTS:
|
|||
inp_refs: []
|
||||
sample_steps: 32
|
||||
if_sr: false
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
MinimaxTTSHTTPStream:
|
||||
# Minimax流式语音合成服务
|
||||
type: minimax_httpstream
|
||||
|
|
@ -918,6 +930,7 @@ TTS:
|
|||
# voice_id: female-shaonv
|
||||
# weight: 1
|
||||
# language_boost: auto
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
AliyunTTS:
|
||||
# 阿里云智能语音交互服务,需要先在阿里云平台开通服务,然后获取验证信息
|
||||
# 平台地址:https://nls-portal.console.aliyun.com/
|
||||
|
|
@ -937,6 +950,7 @@ TTS:
|
|||
# volume: 50
|
||||
# speech_rate: 0
|
||||
# pitch_rate: 0
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
AliyunStreamTTS:
|
||||
# 阿里云CosyVoice大模型流式文本语音合成
|
||||
# 采用FlowingSpeechSynthesizer接口,支持更低延迟和更自然的语音质量
|
||||
|
|
@ -960,6 +974,7 @@ TTS:
|
|||
# volume: 50 # 音量:0-100
|
||||
# speech_rate: 0 # 语速:-500到500
|
||||
# pitch_rate: 0 # 语调:-500到500
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
TencentTTS:
|
||||
# 腾讯云智能语音交互服务,需要先在腾讯云平台开通服务
|
||||
# appid、secret_id、secret_key申请地址:https://console.cloud.tencent.com/cam/capi
|
||||
|
|
@ -971,7 +986,11 @@ TTS:
|
|||
secret_key: 你的腾讯云SecretKey
|
||||
region: ap-guangzhou
|
||||
voice: 101001
|
||||
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
# 以下可不用设置,使用默认设置
|
||||
# format: wav # 音频格式:pcm、wav、mp3
|
||||
# volume: 0 # 音量:-10到10
|
||||
# speech_rate: 0 # 语速:-2到6
|
||||
TTS302AI:
|
||||
# 302AI语音合成服务,需要先在302平台创建账户充值,并获取密钥信息
|
||||
# 添加 302.ai TTS 配置
|
||||
|
|
@ -985,6 +1004,7 @@ TTS:
|
|||
voice: "zh_female_wanwanxiaohe_moon_bigtts"
|
||||
output_dir: tmp/
|
||||
access_token: "你的302API密钥"
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
GizwitsTTS:
|
||||
type: doubao
|
||||
# 火山引擎作为基座,可以完全使用企业级火山引擎语音合成服务
|
||||
|
|
@ -996,6 +1016,7 @@ TTS:
|
|||
voice: "zh_female_wanwanxiaohe_moon_bigtts"
|
||||
output_dir: tmp/
|
||||
access_token: "你的机智云API key"
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
ACGNTTS:
|
||||
#在线网址:https://acgn.ttson.cn/
|
||||
#token购买:www.ttson.cn
|
||||
|
|
@ -1013,6 +1034,7 @@ TTS:
|
|||
format: mp3
|
||||
output_dir: tmp/
|
||||
emotion: 1
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
OpenAITTS:
|
||||
# openai官方文本转语音服务,可支持全球大多数语种
|
||||
type: openai
|
||||
|
|
@ -1028,6 +1050,7 @@ TTS:
|
|||
# 语速范围0.25-4.0
|
||||
speed: 1
|
||||
output_dir: tmp/
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
CustomTTS:
|
||||
# 自定义的TTS接口服务,请求参数可自定义,可接入众多TTS服务
|
||||
# 以本地部署的KokoroTTS为例
|
||||
|
|
@ -1050,6 +1073,7 @@ TTS:
|
|||
# Authorization: Bearer xxxx
|
||||
format: mp3 # 接口返回的音频格式
|
||||
output_dir: tmp/
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
LinkeraiTTS:
|
||||
type: linkerai
|
||||
api_url: https://tts.linkerai.cn/tts
|
||||
|
|
@ -1061,6 +1085,7 @@ TTS:
|
|||
access_token: "U4YdYXVfpwWnk2t5Gp822zWPCuORyeJL"
|
||||
voice: "OUeAo1mhq6IBExi"
|
||||
output_dir: tmp/
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
PaddleSpeechTTS:
|
||||
#百度飞浆 PaddleSpeech 支持本地离线部署 支持模型训练
|
||||
#框架地址 https://www.paddlepaddle.org.cn/
|
||||
|
|
@ -1074,6 +1099,7 @@ TTS:
|
|||
speed: 1.0 # 语速,1.0 表示正常语速,>1 表示加快,<1 表示减慢
|
||||
volume: 1.0 # 音量,1.0 表示正常音量,>1 表示增大,<1 表示减小
|
||||
save_path: # 保存路径
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
IndexStreamTTS:
|
||||
# 基于Index-TTS-vLLM项目的TTS接口服务
|
||||
# 参照教程:https://github.com/Ksuriuri/index-tts-vllm/blob/master/README.md
|
||||
|
|
@ -1083,6 +1109,7 @@ TTS:
|
|||
# 默认音色,如需其他音色可到项目assets文件夹下注册
|
||||
voice: "jay_klee"
|
||||
output_dir: tmp/
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
AliBLTTS:
|
||||
# 阿里百炼CosyVoice大模型流式文本语音合成
|
||||
# 可在这里找到你的 api_key https://bailian.console.aliyun.com/?apiKey=1#/api-key
|
||||
|
|
@ -1097,6 +1124,7 @@ TTS:
|
|||
# volume: 50 # 音量:0-100
|
||||
# rate: 1 # 语速:0.5~2
|
||||
# pitch: 1 # 语调:0.5~2
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
XunFeiTTS:
|
||||
# 讯飞TTS服务 官方网站:https://www.xfyun.cn/
|
||||
# 登录讯飞语音技术平台 https://console.xfyun.cn/app/myapp 创建相关应用
|
||||
|
|
@ -1118,3 +1146,4 @@ TTS:
|
|||
# volume: 50 # 音量:0-100
|
||||
# speed: 50 # 语速:0-100
|
||||
# pitch: 50 # 语调:0-100
|
||||
# language: "中文" # 指定输出语种,如:中文、英语、日语、韩语等,请根据所选音色支持的语言进行设置,不填则默认为中文
|
||||
|
|
|
|||
|
|
@ -134,7 +134,6 @@ class ConnectionHandler:
|
|||
self.asr_audio = []
|
||||
self.asr_audio_queue = queue.Queue()
|
||||
self.current_speaker = None # 存储当前说话人
|
||||
self.current_language_tag = None # 存储当前ASR识别的语言标签
|
||||
|
||||
# llm相关变量
|
||||
self.dialogue = Dialogue()
|
||||
|
|
|
|||
|
|
@ -67,11 +67,6 @@ async def startToChat(conn: "ConnectionHandler", text):
|
|||
conn.current_speaker = speaker_name
|
||||
else:
|
||||
conn.current_speaker = None
|
||||
# 保存语种信息到连接对象
|
||||
if language_tag:
|
||||
conn.current_language_tag = language_tag
|
||||
else:
|
||||
conn.current_language_tag = "zh"
|
||||
|
||||
if conn.need_bind:
|
||||
await check_bind_device(conn)
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import queue
|
|||
import asyncio
|
||||
import traceback
|
||||
import websockets
|
||||
from typing import Callable, Any
|
||||
|
||||
from asyncio import Task
|
||||
from typing import Callable, Any
|
||||
from config.logger import setup_logging
|
||||
from core.utils import opus_encoder_utils
|
||||
from core.utils.tts import MarkdownCleaner
|
||||
from core.providers.tts.base import TTSProviderBase
|
||||
from core.providers.tts.dto.dto import SentenceType, ContentType, InterfaceType
|
||||
|
|
@ -19,6 +19,12 @@ logger = setup_logging()
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "volume", 0, 100, 50, int),
|
||||
("ttsRate", "rate", 0.5, 2.0, 1.0, lambda v: round(v, 1)),
|
||||
("ttsPitch", "pitch", 0.5, 2.0, 1.0, lambda v: round(v, 1)),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
|
||||
|
|
@ -52,6 +58,9 @@ class TTSProvider(TTSProviderBase):
|
|||
pitch = config.get("pitch", "1.0")
|
||||
self.pitch = float(pitch) if pitch else 1.0
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
self.header = {
|
||||
"Authorization": f"Bearer {self.api_key}",
|
||||
# "user-agent": "your_platform_info", // 可选
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
import uuid
|
||||
import json
|
||||
import hmac
|
||||
import time
|
||||
import hashlib
|
||||
import base64
|
||||
import requests
|
||||
from datetime import datetime
|
||||
from core.providers.tts.base import TTSProviderBase
|
||||
from config.logger import setup_logging
|
||||
import time
|
||||
import uuid
|
||||
|
||||
from urllib import parse
|
||||
from datetime import datetime
|
||||
from config.logger import setup_logging
|
||||
from core.providers.tts.base import TTSProviderBase
|
||||
from core.utils.tts import convert_percentage_to_range
|
||||
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
|
@ -84,6 +86,11 @@ class AccessToken:
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "volume", 0, 100, 50, int),
|
||||
("ttsRate", "speech_rate", -500, 500, 0, int),
|
||||
("ttsPitch", "pitch_rate", -500, 500, 0, int),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
|
|
@ -93,7 +100,6 @@ class TTSProvider(TTSProviderBase):
|
|||
self.access_key_secret = config.get("access_key_secret")
|
||||
|
||||
self.appkey = config.get("appkey")
|
||||
self.format = config.get("format", "wav")
|
||||
self.audio_file_type = config.get("format", "wav")
|
||||
|
||||
if config.get("private_voice"):
|
||||
|
|
@ -110,6 +116,9 @@ class TTSProvider(TTSProviderBase):
|
|||
pitch_rate = config.get("pitch_rate", "0")
|
||||
self.pitch_rate = int(pitch_rate) if pitch_rate else 0
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
self.host = config.get("host", "nls-gateway-cn-shanghai.aliyuncs.com")
|
||||
self.api_url = f"https://{self.host}/stream/v1/tts"
|
||||
self.header = {"Content-Type": "application/json"}
|
||||
|
|
@ -169,7 +178,7 @@ class TTSProvider(TTSProviderBase):
|
|||
"appkey": self.appkey,
|
||||
"token": self.token,
|
||||
"text": text,
|
||||
"format": self.format,
|
||||
"format": self.audio_file_type,
|
||||
"sample_rate": self.conn.sample_rate,
|
||||
"voice": self.voice,
|
||||
"volume": self.volume,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import random
|
||||
import os
|
||||
import uuid
|
||||
import json
|
||||
import hmac
|
||||
|
|
@ -8,17 +8,17 @@ import time
|
|||
import queue
|
||||
import asyncio
|
||||
import traceback
|
||||
from typing import Callable, Any
|
||||
from asyncio import Task
|
||||
import websockets
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
from asyncio import Task
|
||||
from urllib import parse
|
||||
from datetime import datetime
|
||||
from typing import Callable, Any
|
||||
from config.logger import setup_logging
|
||||
from core.utils.tts import MarkdownCleaner
|
||||
from core.providers.tts.base import TTSProviderBase
|
||||
from core.providers.tts.dto.dto import SentenceType, ContentType, InterfaceType
|
||||
from core.utils.tts import MarkdownCleaner
|
||||
from core.utils import opus_encoder_utils, textUtils
|
||||
from config.logger import setup_logging
|
||||
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
|
@ -87,6 +87,12 @@ class AccessToken:
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "volume", 0, 100, 50, int),
|
||||
("ttsRate", "speech_rate", -500, 500, 0, int),
|
||||
("ttsPitch", "pitch_rate", -500, 500, 0, int),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
|
||||
|
|
@ -98,7 +104,6 @@ class TTSProvider(TTSProviderBase):
|
|||
self.access_key_secret = config.get("access_key_secret")
|
||||
self.appkey = config.get("appkey")
|
||||
self.format = config.get("format", "pcm")
|
||||
self.audio_file_type = config.get("format", "pcm")
|
||||
|
||||
# 音色配置 - CosyVoice大模型音色
|
||||
if config.get("private_voice"):
|
||||
|
|
@ -116,6 +121,9 @@ class TTSProvider(TTSProviderBase):
|
|||
pitch_rate = config.get("pitch_rate", "0")
|
||||
self.pitch_rate = int(pitch_rate) if pitch_rate else 0
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
# WebSocket配置
|
||||
self.host = config.get("host", "nls-gateway-cn-beijing.aliyuncs.com")
|
||||
# 如果配置的是内网地址(包含-internal.aliyuncs.com),则使用ws协议,默认是wss协议
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from typing import Callable, Any
|
|||
from abc import ABC, abstractmethod
|
||||
from config.logger import setup_logging
|
||||
from core.utils import opus_encoder_utils
|
||||
from core.utils.tts import MarkdownCleaner
|
||||
from core.utils.tts import MarkdownCleaner, convert_percentage_to_range
|
||||
from core.utils.output_counter import add_device_output
|
||||
from core.handle.reportHandle import enqueue_tts_report
|
||||
from core.handle.sendAudioHandle import sendAudioMessage
|
||||
|
|
@ -463,3 +463,10 @@ class TTSProviderBase(ABC):
|
|||
self.processed_chars += len(full_text)
|
||||
return True
|
||||
return False
|
||||
|
||||
def _apply_percentage_params(self, config):
|
||||
"""根据子类定义的 TTS_PARAM_CONFIG 批量应用百分比参数"""
|
||||
for config_key, attr_name, min_val, max_val, base_val, transform in self.TTS_PARAM_CONFIG:
|
||||
if config_key in config:
|
||||
val = convert_percentage_to_range(config[config_key], min_val, max_val, base_val)
|
||||
setattr(self, attr_name, transform(val) if transform else val)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from core.providers.tts.base import TTSProviderBase
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("speed", "speed", 0.5, 2, 1, lambda v: round(float(v), 1)),
|
||||
("loudness_rate", "loudness_rate", -50, 100, 0, int),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
self.model = config.get("model")
|
||||
|
|
@ -11,17 +16,29 @@ class TTSProvider(TTSProviderBase):
|
|||
self.voice = config.get("private_voice")
|
||||
else:
|
||||
self.voice = config.get("voice")
|
||||
self.response_format = config.get("response_format", "wav")
|
||||
self.audio_file_type = config.get("response_format", "wav")
|
||||
self.host = "api.coze.cn"
|
||||
self.api_url = f"https://{self.host}/v1/audio/speech"
|
||||
|
||||
# 音频参数配置
|
||||
speed = config.get("speed", "0")
|
||||
self.speed = int(speed) if speed else 0
|
||||
|
||||
loudness_rate = config.get("loudness_rate", "0")
|
||||
self.loudness_rate = int(loudness_rate) if loudness_rate else 0
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
async def text_to_speak(self, text, output_file):
|
||||
request_json = {
|
||||
"model": self.model,
|
||||
"input": text,
|
||||
"voice_id": self.voice,
|
||||
"response_format": self.response_format,
|
||||
"response_format": self.audio_file_type,
|
||||
"sample_rate": self.conn.sample_rate,
|
||||
"speed": self.speed,
|
||||
"loudness_rate": self.loudness_rate,
|
||||
}
|
||||
headers = {
|
||||
"Authorization": f"Bearer {self.access_token}",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ class TTSProvider(TTSProviderBase):
|
|||
self.url = config.get("url")
|
||||
self.method = config.get("method", "GET")
|
||||
self.headers = config.get("headers", {})
|
||||
self.format = config.get("format", "wav")
|
||||
self.audio_file_type = config.get("format", "wav")
|
||||
self.output_file = config.get("output_dir", "tmp/")
|
||||
self.params = config.get("params")
|
||||
|
|
@ -29,7 +28,7 @@ class TTSProvider(TTSProviderBase):
|
|||
raise TypeError("Custom TTS配置参数出错, 请参考配置说明")
|
||||
|
||||
def generate_filename(self):
|
||||
return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}.{self.format}")
|
||||
return os.path.join(self.output_file, f"tts-{datetime.now().date()}@{uuid.uuid4().hex}.{self.audio_file_type}")
|
||||
|
||||
async def text_to_speak(self, text, output_file):
|
||||
request_params = {}
|
||||
|
|
|
|||
|
|
@ -2,15 +2,24 @@ import uuid
|
|||
import json
|
||||
import base64
|
||||
import requests
|
||||
|
||||
from config.logger import setup_logging
|
||||
from core.utils.util import check_model_key
|
||||
from core.providers.tts.base import TTSProviderBase
|
||||
from config.logger import setup_logging
|
||||
from core.utils.tts import convert_percentage_to_range
|
||||
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "volume_ratio", 0.1, 3, 1.0, lambda v: round(float(v), 1)),
|
||||
("ttsRate", "speed_ratio", 0.2, 3, 1.0, lambda v: round(float(v), 1)),
|
||||
("ttsPitch", "pitch_ratio", 0.1, 3, 1.0, lambda v: round(float(v), 1)),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
if config.get("appid"):
|
||||
|
|
@ -34,6 +43,9 @@ class TTSProvider(TTSProviderBase):
|
|||
self.volume_ratio = float(volume_ratio) if volume_ratio else 1.0
|
||||
self.pitch_ratio = float(pitch_ratio) if pitch_ratio else 1.0
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
self.api_url = config.get("api_url")
|
||||
self.authorization = config.get("authorization")
|
||||
self.header = {"Authorization": f"{self.authorization}{self.access_token}"}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ class TTSProvider(TTSProviderBase):
|
|||
self.reference_text = parse_string_to_list(
|
||||
config.get('ref_text')if config.get('ref_text') else config.get("reference_text")
|
||||
)
|
||||
self.format = config.get("response_format", "wav")
|
||||
self.audio_file_type = config.get("response_format", "wav")
|
||||
self.api_key = config.get("api_key", "YOUR_API_KEY")
|
||||
model_key_msg = check_model_key("FishSpeech TTS", self.api_key)
|
||||
|
|
@ -148,7 +147,7 @@ class TTSProvider(TTSProviderBase):
|
|||
],
|
||||
"reference_id": self.reference_id,
|
||||
"normalize": self.normalize,
|
||||
"format": self.format,
|
||||
"format": self.audio_file_type,
|
||||
"max_new_tokens": self.max_new_tokens,
|
||||
"chunk_length": self.chunk_length,
|
||||
"top_p": self.top_p,
|
||||
|
|
|
|||
|
|
@ -7,11 +7,10 @@ import traceback
|
|||
import websockets
|
||||
|
||||
from typing import Callable, Any
|
||||
from core.utils.tts import MarkdownCleaner
|
||||
from config.logger import setup_logging
|
||||
from core.utils import opus_encoder_utils
|
||||
from core.utils.util import check_model_key
|
||||
from core.providers.tts.base import TTSProviderBase
|
||||
from core.utils.tts import MarkdownCleaner, convert_percentage_to_range
|
||||
from core.providers.tts.dto.dto import SentenceType, ContentType, InterfaceType
|
||||
|
||||
|
||||
|
|
@ -178,6 +177,22 @@ class TTSProvider(TTSProviderBase):
|
|||
self.additions = {**default_additions, **config.get("additions", {})}
|
||||
self.mix_speaker = {**default_mix_speaker, **config.get("mix_speaker", {})}
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
if "ttsVolume" in config:
|
||||
self.audio_params["loudness_rate"] = int(convert_percentage_to_range(
|
||||
config["ttsVolume"], min_val=-50, max_val=100, base_val=0
|
||||
))
|
||||
|
||||
if "ttsRate" in config:
|
||||
self.audio_params["speech_rate"] = int(convert_percentage_to_range(
|
||||
config["ttsRate"], min_val=-50, max_val=100, base_val=0
|
||||
))
|
||||
|
||||
if "ttsPitch" in config:
|
||||
self.additions["post_process"]["pitch"] = int(convert_percentage_to_range(
|
||||
config["ttsPitch"], min_val=-12, max_val=12, base_val=0
|
||||
))
|
||||
|
||||
self.ws_url = config.get("ws_url")
|
||||
self.authorization = config.get("authorization")
|
||||
self.header = {"Authorization": f"{self.authorization}{self.access_token}"}
|
||||
|
|
|
|||
|
|
@ -6,12 +6,14 @@ import asyncio
|
|||
import aiohttp
|
||||
import requests
|
||||
import traceback
|
||||
|
||||
from core.utils import textUtils
|
||||
from config.logger import setup_logging
|
||||
from core.utils.tts import MarkdownCleaner
|
||||
from core.utils.util import parse_string_to_list
|
||||
from core.providers.tts.base import TTSProviderBase
|
||||
from core.utils import opus_encoder_utils, textUtils
|
||||
from core.providers.tts.dto.dto import SentenceType, ContentType
|
||||
from core.utils.tts import MarkdownCleaner, convert_percentage_to_range
|
||||
|
||||
|
||||
TAG = __name__
|
||||
logger = setup_logging()
|
||||
|
|
@ -56,6 +58,22 @@ class TTSProvider(TTSProviderBase):
|
|||
if self.voice:
|
||||
self.voice_setting["voice_id"] = self.voice
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
if "ttsVolume" in config:
|
||||
self.voice_setting["vol"] = round(convert_percentage_to_range(
|
||||
config["ttsVolume"], min_val=0.1, max_val=10, base_val=1.0
|
||||
), 1)
|
||||
|
||||
if "ttsRate" in config:
|
||||
self.voice_setting["speed"] = round(convert_percentage_to_range(
|
||||
config["ttsRate"], min_val=0.5, max_val=2, base_val=1.0
|
||||
), 1)
|
||||
|
||||
if "ttsPitch" in config:
|
||||
self.voice_setting["pitch"] = int(convert_percentage_to_range(
|
||||
config["ttsPitch"], min_val=-12, max_val=12, base_val=0
|
||||
))
|
||||
|
||||
self.host = "api.minimaxi.com" # 备用地址:api-bj.minimaxi.com
|
||||
self.api_url = f"https://{self.host}/v1/t2a_v2?GroupId={self.group_id}"
|
||||
self.header = {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,10 @@ logger = setup_logging()
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsRate", "speed", 0.25, 4, 1, lambda v: round(float(v), 2)),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
self.api_key = config.get("api_key")
|
||||
|
|
@ -17,13 +21,15 @@ class TTSProvider(TTSProviderBase):
|
|||
self.voice = config.get("private_voice")
|
||||
else:
|
||||
self.voice = config.get("voice", "alloy")
|
||||
self.response_format = config.get("format", "wav")
|
||||
self.audio_file_type = config.get("format", "wav")
|
||||
|
||||
# 处理空字符串的情况
|
||||
speed = config.get("speed", "1.0")
|
||||
self.speed = float(speed) if speed else 1.0
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
self.output_file = config.get("output_dir", "tmp/")
|
||||
model_key_msg = check_model_key("TTS", self.api_key)
|
||||
if model_key_msg:
|
||||
|
|
@ -38,7 +44,7 @@ class TTSProvider(TTSProviderBase):
|
|||
"model": self.model,
|
||||
"input": text,
|
||||
"voice": self.voice,
|
||||
"response_format": "wav",
|
||||
"response_format": self.audio_file_type,
|
||||
"speed": self.speed,
|
||||
}
|
||||
response = requests.post(self.api_url, json=data, headers=headers)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ logger = setup_logging()
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "volume", 0, 3, 1.0, lambda v: round(float(v), 1)),
|
||||
("ttsRate", "speed", 0, 3, 1.0, lambda v: round(float(v), 1)),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
self.url = config.get("url", "ws://192.168.1.10:8092/paddlespeech/tts/streaming")
|
||||
|
|
@ -33,6 +38,10 @@ class TTSProvider(TTSProviderBase):
|
|||
self.volume = float(volume) if volume else 1.0
|
||||
|
||||
self.delete_audio_file = config.get("delete_audio", True)
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
if not self.delete_audio_file:
|
||||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||||
save_path = config.get("save_path")
|
||||
|
|
|
|||
|
|
@ -3,6 +3,11 @@ from core.providers.tts.base import TTSProviderBase
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "gain", -10, 10, 0, int),
|
||||
("ttsRate", "speed", 0.25, 4, 1, lambda v: round(float(v), 2)),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
self.model = config.get("model")
|
||||
|
|
@ -11,11 +16,13 @@ class TTSProvider(TTSProviderBase):
|
|||
self.voice = config.get("private_voice")
|
||||
else:
|
||||
self.voice = config.get("voice")
|
||||
self.response_format = config.get("response_format", "mp3")
|
||||
self.audio_file_type = config.get("response_format", "mp3")
|
||||
self.speed = float(config.get("speed", 1.0))
|
||||
self.gain = config.get("gain")
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
self.host = "api.siliconflow.cn"
|
||||
self.api_url = f"https://{self.host}/v1/audio/speech"
|
||||
|
||||
|
|
@ -24,7 +31,7 @@ class TTSProvider(TTSProviderBase):
|
|||
"model": self.model,
|
||||
"input": text,
|
||||
"voice": self.voice,
|
||||
"response_format": self.response_format,
|
||||
"response_format": self.audio_file_type,
|
||||
}
|
||||
headers = {
|
||||
"Authorization": f"Bearer {self.access_token}",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ from core.providers.tts.base import TTSProviderBase
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "volume", -10, 10, 0, lambda v: round(float(v), 1)),
|
||||
("ttsRate", "speed", -2, 6, 0, lambda v: round(float(v), 2)),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
self.appid = config.get("appid")
|
||||
|
|
@ -24,6 +29,16 @@ class TTSProvider(TTSProviderBase):
|
|||
self.output_file = config.get("output_dir")
|
||||
self.audio_file_type = config.get("format", "wav")
|
||||
|
||||
# 音频参数配置
|
||||
speed = config.get("speed", "0")
|
||||
self.speed = int(speed) if speed else 0
|
||||
|
||||
volume = config.get("volume", "0")
|
||||
self.volume = int(volume) if volume else 0
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
def _get_auth_headers(self, request_body):
|
||||
"""生成鉴权请求头"""
|
||||
# 获取当前UTC时间戳
|
||||
|
|
@ -127,6 +142,10 @@ class TTSProvider(TTSProviderBase):
|
|||
"Text": text, # 合成语音的源文本
|
||||
"SessionId": str(uuid.uuid4()), # 会话ID,随机生成
|
||||
"VoiceType": int(self.voice), # 音色
|
||||
"Codec": self.audio_file_type, # 音频编码格式
|
||||
"Volume": self.volume, # 音量
|
||||
"Speed": self.speed, # 语速
|
||||
"SampleRate": self.conn.sample_rate, # 采样率部分支持24000
|
||||
}
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -12,6 +12,12 @@ logger = setup_logging()
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "volume_change_dB", -10, 10, 0, int),
|
||||
("ttsRate", "speed_factor", 0.5, 2, 0, lambda v: round(float(v), 1)),
|
||||
("ttsPitch", "pitch_factor", -8, 8, 0, lambda v: round(float(v), 1)),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
self.url = config.get(
|
||||
|
|
@ -29,11 +35,13 @@ class TTSProvider(TTSProviderBase):
|
|||
self.stream = str(config.get("stream", False)).lower() in ("true", "1", "yes")
|
||||
self.output_file = config.get("output_dir")
|
||||
self.pitch_factor = int(config.get("pitch_factor", 0))
|
||||
self.format = config.get("format", "mp3")
|
||||
self.audio_file_type = config.get("format", "mp3")
|
||||
self.emotion = int(config.get("emotion", 1))
|
||||
self.header = {"Content-Type": "application/json"}
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
def generate_filename(self, extension=".mp3"):
|
||||
return os.path.join(
|
||||
self.output_file,
|
||||
|
|
@ -48,7 +56,7 @@ class TTSProvider(TTSProviderBase):
|
|||
"to_lang": self.to_lang,
|
||||
"text": text,
|
||||
"emotion": self.emotion,
|
||||
"format": self.format,
|
||||
"format": self.audio_file_type,
|
||||
"volume_change_dB": self.volume_change_dB,
|
||||
"voice_id": self.voice,
|
||||
"pitch_factor": self.pitch_factor,
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import hashlib
|
|||
import asyncio
|
||||
import traceback
|
||||
import websockets
|
||||
from typing import Callable, Any
|
||||
|
||||
from asyncio import Task
|
||||
from typing import Callable, Any
|
||||
from config.logger import setup_logging
|
||||
from core.utils import opus_encoder_utils
|
||||
from core.utils.tts import MarkdownCleaner
|
||||
from urllib.parse import urlencode, urlparse
|
||||
from core.providers.tts.base import TTSProviderBase
|
||||
|
|
@ -60,6 +60,12 @@ class XunfeiWSAuth:
|
|||
|
||||
|
||||
class TTSProvider(TTSProviderBase):
|
||||
TTS_PARAM_CONFIG = [
|
||||
("ttsVolume", "volume", 0, 100, 50, int),
|
||||
("ttsRate", "speed", 0, 100, 50, int),
|
||||
("ttsPitch", "pitch", 0, 100, 50, int),
|
||||
]
|
||||
|
||||
def __init__(self, config, delete_audio_file):
|
||||
super().__init__(config, delete_audio_file)
|
||||
|
||||
|
|
@ -89,6 +95,9 @@ class TTSProvider(TTSProviderBase):
|
|||
pitch = config.get("pitch", "50")
|
||||
self.pitch = int(pitch) if pitch else 50
|
||||
|
||||
# 应用百分比调整(如果存在),否则使用公有化配置
|
||||
self._apply_percentage_params(config)
|
||||
|
||||
# 音频编码配置
|
||||
self.format = config.get("format", "raw")
|
||||
|
||||
|
|
|
|||
|
|
@ -251,6 +251,15 @@ class PromptManager:
|
|||
or ""
|
||||
)
|
||||
|
||||
# 获取TTS选择的语言,默认值为中文
|
||||
language = (
|
||||
self.config.get("TTS", {})
|
||||
.get(self.config.get("selected_module", {}).get("TTS", ""), {})
|
||||
.get("language")
|
||||
or "中文"
|
||||
)
|
||||
self.logger.bind(tag=TAG).debug(f"获取到选择的语言: {language}")
|
||||
|
||||
# 替换模板变量
|
||||
template = Template(self.base_prompt_template)
|
||||
enhanced_prompt = template.render(
|
||||
|
|
@ -265,6 +274,7 @@ class PromptManager:
|
|||
device_id=device_id,
|
||||
client_ip=client_ip,
|
||||
dynamic_context=self.context_data,
|
||||
language=language,
|
||||
*args,
|
||||
**kwargs,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -142,3 +142,29 @@ class MarkdownCleaner:
|
|||
text = check_emoji(text)
|
||||
|
||||
return text.strip()
|
||||
|
||||
def convert_percentage_to_range(percentage, min_val, max_val, base_val=None):
|
||||
"""
|
||||
将百分比(-100~100)转换为指定范围的值
|
||||
|
||||
Args:
|
||||
percentage: 百分比值 (-100 到 100)
|
||||
min_val: 目标范围最小值
|
||||
max_val: 目标范围最大值
|
||||
base_val: 基准值(可选,默认为范围中点)
|
||||
|
||||
Returns:
|
||||
转换后的值
|
||||
"""
|
||||
percentage, min_val, max_val = float(percentage), float(min_val), float(max_val)
|
||||
base_val = float(base_val) if base_val is not None else (min_val + max_val) / 2
|
||||
|
||||
if percentage < 0:
|
||||
# 负百分比:从 base_val 向 min_val 线性插值
|
||||
result = base_val + (base_val - min_val) * (percentage / 100)
|
||||
else:
|
||||
# 正百分比:从 base_val 向 max_val 线性插值
|
||||
result = base_val + (max_val - base_val) * (percentage / 100)
|
||||
|
||||
# 确保结果在有效范围内
|
||||
return max(min_val, min(max_val, result))
|
||||
|
|
|
|||
Loading…
Reference in a new issue