mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-24 08:03:53 +08:00
Merge branch 'main' into sm2_test
This commit is contained in:
@@ -161,11 +161,8 @@ public interface ErrorCode {
|
||||
int MQTT_SECRET_LENGTH_INSECURE = 10123; // mqtt密钥长度不安全
|
||||
int MQTT_SECRET_CHARACTER_INSECURE = 10124; // mqtt密钥必须同时包含大小写字母
|
||||
int MQTT_SECRET_WEAK_PASSWORD = 10125; // mqtt密钥包含弱密码
|
||||
|
||||
// 字典相关错误码
|
||||
int DICT_LABEL_DUPLICATE = 10128; // 字典标签重复
|
||||
|
||||
// SM2加密相关错误码
|
||||
int SM2_KEY_NOT_CONFIGURED = 10129; // SM2密钥未配置
|
||||
int SM2_DECRYPT_ERROR = 10130; // SM2解密失败
|
||||
int MODEL_TYPE_PROVIDE_CODE_NOT_NULL = 10131; // modelType和provideCode不能为空
|
||||
}
|
||||
|
||||
+17
@@ -134,6 +134,10 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
||||
// 清理redis缓存
|
||||
redisUtils.delete(cacheDeviceKey);
|
||||
redisUtils.delete(deviceKey);
|
||||
|
||||
// 添加:清除智能体设备数量缓存
|
||||
redisUtils.delete(RedisKeys.getAgentDeviceCountById(agentId));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -225,6 +229,16 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
||||
|
||||
@Override
|
||||
public void unbindDevice(Long userId, String deviceId) {
|
||||
// 先查询设备信息,获取agentId
|
||||
DeviceEntity device = baseDao.selectById(deviceId);
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isNotBlank(device.getAgentId())) {
|
||||
// 清除智能体设备数量缓存
|
||||
redisUtils.delete(RedisKeys.getAgentDeviceCountById(device.getAgentId()));
|
||||
}
|
||||
|
||||
UpdateWrapper<DeviceEntity> wrapper = new UpdateWrapper<>();
|
||||
wrapper.eq("user_id", userId);
|
||||
wrapper.eq("id", deviceId);
|
||||
@@ -459,6 +473,9 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
|
||||
entity.setUpdater(userId);
|
||||
entity.setAutoUpdate(1);
|
||||
baseDao.insert(entity);
|
||||
|
||||
// 添加:清除智能体设备数量缓存
|
||||
redisUtils.delete(RedisKeys.getAgentDeviceCountById(dto.getAgentId()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -105,7 +105,7 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
|
||||
public ModelConfigDTO add(String modelType, String provideCode, ModelConfigBodyDTO modelConfigBodyDTO) {
|
||||
// 先验证有没有供应器
|
||||
if (StringUtils.isBlank(modelType) || StringUtils.isBlank(provideCode)) {
|
||||
throw new RenException("modelType和provideCode不能为空");
|
||||
throw new RenException(ErrorCode.MODEL_TYPE_PROVIDE_CODE_NOT_NULL);
|
||||
}
|
||||
List<ModelProviderDTO> providerList = modelProviderService.getList(modelType, provideCode);
|
||||
if (CollectionUtil.isEmpty(providerList)) {
|
||||
@@ -124,7 +124,7 @@ public class ModelConfigServiceImpl extends BaseServiceImpl<ModelConfigDao, Mode
|
||||
public ModelConfigDTO edit(String modelType, String provideCode, String id, ModelConfigBodyDTO modelConfigBodyDTO) {
|
||||
// 先验证有没有供应器
|
||||
if (StringUtils.isBlank(modelType) || StringUtils.isBlank(provideCode)) {
|
||||
throw new RenException("modelType和provideCode不能为空");
|
||||
throw new RenException(ErrorCode.MODEL_TYPE_PROVIDE_CODE_NOT_NULL);
|
||||
}
|
||||
List<ModelProviderDTO> providerList = modelProviderService.getList(modelType, provideCode);
|
||||
if (CollectionUtil.isEmpty(providerList)) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
-- 添加讯飞流式TTS供应器
|
||||
delete from `ai_model_provider` where id = 'SYSTEM_TTS_XunFeiStreamTTS';
|
||||
INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES
|
||||
('SYSTEM_TTS_XunFeiStreamTTS', 'TTS', 'xunfei_stream', '讯飞流式语音合成', '[{"key":"app_id","label":"APP_ID","type":"string"},{"key":"api_secret","label":"API_Secret","type":"string"},{"key":"api_key","label":"API密钥","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"},{"key":"voice","label":"音色","type":"string"},{"key":"format","label":"音频格式","type":"string"},{"key":"sample_rate","label":"采样率","type":"number"},{"key": "volume", "type": "number", "label": "音量"},{"key": "speed", "type": "number", "label": "语速"},{"key": "pitch", "type": "number", "label": "音调"},{"key": "oral_level", "type": "number", "label": "口语化等级"},{"key": "spark_assist", "type": "number", "label": "是否口语化"},{"key": "stop_split", "type": "number", "label": "服务端拆句"},{"key": "remain", "type": "number", "label": "保留书面语"}]', 20, 1, NOW(), 1, NOW());
|
||||
|
||||
-- 添加讯飞流式TTS模型配置
|
||||
delete from `ai_model_config` where id = 'TTS_XunFeiStreamTTS';
|
||||
INSERT INTO `ai_model_config` VALUES ('TTS_XunFeiStreamTTS', 'TTS', 'XunFeiStreamTTS', '讯飞流式语音合成', 0, 1, '{\"type\": \"xunfei_stream\", \"app_id\": \"\", \"api_secret\": \"\", \"api_key\": \"\", \"output_dir\": \"tmp/\", \"voice\": \"x5_lingxiaoxuan_flow\", \"format\": \"raw\", \"sample_rate\": 24000, \"volume\": 50, \"speed\": 50, \"pitch\": 50, \"oral_level\": \"mid\", \"spark_assist\": 1, \"stop_split\": 0, \"remain\": 0}', NULL, NULL, 23, NULL, NULL, NULL, NULL);
|
||||
|
||||
-- 更新讯飞流式TTS配置说明
|
||||
UPDATE `ai_model_config` SET
|
||||
`doc_link` = 'https://console.xfyun.cn/app/myapp',
|
||||
`remark` = '讯飞流式TTS说明:
|
||||
1. 登录讯飞语音技术平台 https://console.xfyun.cn/app/myapp 创建相关应用
|
||||
2. 选择需要的服务获取api相关配置 https://console.xfyun.cn/services/uts
|
||||
3. 为需要使用的应用(APPID)购买相关服务 例如:超拟人合成 https://console.xfyun.cn/services/uts
|
||||
5. 支持实时双流式通信,具有较低的延迟
|
||||
6. 支持口语化设置和音频参数调整 注意:V5音色不支持相关口语化配置
|
||||
7. 支持实时调节音量、语速、音调等参数
|
||||
' WHERE `id` = 'TTS_XunFeiStreamTTS';
|
||||
|
||||
-- 添加讯飞流式TTS音色
|
||||
delete from `ai_tts_voice` where tts_model_id = 'TTS_XunFeiStreamTTS';
|
||||
|
||||
-- 基础角色
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0001', 'TTS_XunFeiStreamTTS', '聆小璇', 'x5_lingxiaoxuan_flow', '中文', NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0002', 'TTS_XunFeiStreamTTS', '聆飞逸', 'x5_lingfeiyi_flow', '中文', NULL, NULL, NULL, NULL, 2, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0003', 'TTS_XunFeiStreamTTS', '聆小玥', 'x5_lingxiaoyue_flow', '中文', NULL, NULL, NULL, NULL, 3, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0004', 'TTS_XunFeiStreamTTS', '聆玉昭', 'x5_lingyuzhao_flow', '中文', NULL, NULL, NULL, NULL, 4, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0005', 'TTS_XunFeiStreamTTS', '聆玉言', 'x5_lingyuyan_flow', '中文', NULL, NULL, NULL, NULL, 5, NULL, NULL, NULL, NULL);
|
||||
|
||||
-- 需要添加对应的角色音色
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0006', 'TTS_XunFeiStreamTTS', '聆飞哲', 'x4_lingfeizhe_oral', '中文', NULL, NULL, NULL, NULL, 6, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0007', 'TTS_XunFeiStreamTTS', '聆小璃', 'x4_lingxiaoli_oral', '中文', NULL, NULL, NULL, NULL, 7, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0008', 'TTS_XunFeiStreamTTS', '聆小糖', 'x5_lingxiaotang_flow', '中文', NULL, NULL, NULL, NULL, 8, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0009', 'TTS_XunFeiStreamTTS', '聆小琪', 'x4_lingxiaoqi_oral', '中文', NULL, NULL, NULL, NULL, 9, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0010', 'TTS_XunFeiStreamTTS', '聆佑佑-童年女声', 'x4_lingyouyou_oral', '中文', NULL, NULL, NULL, NULL, 10, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0011', 'TTS_XunFeiStreamTTS', '子津', 'x4_zijin_oral', '天津话', NULL, NULL, NULL, NULL, 11, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0012', 'TTS_XunFeiStreamTTS', '子阳', 'x4_ziyang_oral', '东北话', NULL, NULL, NULL, NULL, 12, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0013', 'TTS_XunFeiStreamTTS', 'Grant', 'x5_EnUs_Grant_flow', '英文', NULL, NULL, NULL, NULL, 13, NULL, NULL, NULL, NULL);
|
||||
INSERT INTO `ai_tts_voice` VALUES ('TTS_XunFeiStreamTTS_0014', 'TTS_XunFeiStreamTTS', 'Lila', 'x5_EnUs_Lila_flow', '英文', NULL, NULL, NULL, NULL, 14, NULL, NULL, NULL, NULL);
|
||||
@@ -0,0 +1,26 @@
|
||||
-- 添加讯飞流式语音识别服务配置
|
||||
delete from `ai_model_provider` where id = 'SYSTEM_ASR_XunfeiStream';
|
||||
INSERT INTO `ai_model_provider` (`id`, `model_type`, `provider_code`, `name`, `fields`, `sort`, `creator`, `create_date`, `updater`, `update_date`) VALUES
|
||||
('SYSTEM_ASR_XunfeiStream', 'ASR', 'xunfei_stream', '讯飞流式语音识别', '[{"key":"app_id","label":"应用ID","type":"string"},{"key":"api_key","label":"API_KEY","type":"password"},{"key":"api_secret","label":"API_SECRET","type":"password"},{"key":"domain","label":"识别领域","type":"string"},{"key":"language","label":"识别语言","type":"string"},{"key":"accent","label":"方言","type":"string"},{"key":"dwa","label":"动态修正","type":"string"},{"key":"output_dir","label":"输出目录","type":"string"}]', 18, 1, NOW(), 1, NOW());
|
||||
|
||||
delete from `ai_model_config` where id = 'ASR_XunfeiStream';
|
||||
INSERT INTO `ai_model_config` VALUES ('ASR_XunfeiStream', 'ASR', '讯飞流式语音识别', '讯飞流式语音识别服务', 0, 1, '{"type": "xunfei_stream", "app_id": "", "api_key": "", "api_secret": "", "domain": "slm", "language": "zh_cn", "accent": "mandarin", "dwa": "wpgs", "output_dir": "tmp/"}', 'https://www.xfyun.cn/doc/spark/spark_zh_iat.html', '支持实时流式语音识别,适用于中文普通话及多种方言识别', 21, NULL, NULL, NULL, NULL);
|
||||
|
||||
-- 更新讯飞流式语音识别模型配置的说明文档
|
||||
UPDATE `ai_model_config` SET
|
||||
`doc_link` = 'https://www.xfyun.cn/doc/spark/spark_zh_iat.html',
|
||||
`remark` = '讯飞流式语音识别配置说明:
|
||||
1. 登录讯飞开放平台 https://www.xfyun.cn/
|
||||
2. 创建语音识别应用获取APPID、APISecret、APIKey
|
||||
3. 参数说明:
|
||||
- app_id: 应用ID,在讯飞开放平台创建应用后获得
|
||||
- api_key: API密钥,用于接口鉴权
|
||||
- api_secret: API密钥,用于生成签名
|
||||
- domain: 识别领域,默认slm(智能化语音转写)
|
||||
- language: 识别语言,默认zh_cn(中文)
|
||||
- accent: 方言类型,默认mandarin(普通话),支持cantonese(粤语)等
|
||||
- dwa: 动态修正,默认wpgs(开启动态修正)
|
||||
- output_dir: 音频文件输出目录,默认tmp/
|
||||
4. 支持实时流式识别,适用于实时语音交互场景
|
||||
5. 支持多种方言和语言识别
|
||||
' WHERE `id` = 'ASR_XunfeiStream';
|
||||
@@ -0,0 +1,19 @@
|
||||
delete from `ai_model_config` where id = 'LLM_XunfeiSparkLLM';
|
||||
INSERT INTO `ai_model_config` VALUES ('LLM_XunfeiSparkLLM', 'LLM', '讯飞星火认知大模型', '讯飞星火认知大模型', 0, 1, '{"type": "openai", "model_name": "generalv3.5", "base_url": "https://spark-api-open.xf-yun.com/v1", "api_password": "你的api_password", "temperature": 0.5, "max_tokens": 2048, "top_p": 1.0, "frequency_penalty": 0.0}', 'https://www.xfyun.cn/doc/spark/HTTP%E8%B0%83%E7%94%A8%E6%96%87%E6%A1%A3.html', '讯飞星火认知大模型,支持多轮对话、文本生成等功能', 14, NULL, NULL, NULL, NULL);
|
||||
|
||||
-- 更新讯飞星火认知大模型配置的说明文档
|
||||
UPDATE `ai_model_config` SET
|
||||
`doc_link` = 'https://www.xfyun.cn/doc/spark/HTTP%E8%B0%83%E7%94%A8%E6%96%87%E6%A1%A3.html',
|
||||
`remark` = '讯飞星火认知大模型配置说明:
|
||||
1. 登录讯飞开放平台 https://www.xfyun.cn/,每一个模型对应每一个api_password,更改模型时需要查看对应模型的api_password
|
||||
2. 创建星火认知大模型应用获取API Password
|
||||
3. 参数说明:
|
||||
- api_password: API Password,在讯飞开放平台创建应用后获得
|
||||
- model_name: 模型名称,支持generalv3.5、generalv3等版本
|
||||
- base_url: API地址,默认https://spark-api-open.xf-yun.com/v1
|
||||
- temperature: 温度参数,控制生成随机性,范围0-1,默认0.5
|
||||
- max_tokens: 最大输出token数,默认2048
|
||||
- top_p: 核心采样参数,控制词汇多样性,默认1.0
|
||||
- frequency_penalty: 频率惩罚,降低重复内容,默认0.0
|
||||
4. 每一个模型对应每一个api_password,更改模型时需要查看对应模型的api_password。
|
||||
' WHERE `id` = 'LLM_XunfeiSparkLLM';
|
||||
@@ -366,3 +366,25 @@ databaseChangeLog:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202509221530.sql
|
||||
- changeSet:
|
||||
id: 202509191545
|
||||
author: RanChen
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202509191545.sql
|
||||
- changeSet:
|
||||
id: 202509220926
|
||||
author: fyb
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202509220926.sql
|
||||
|
||||
- changeSet:
|
||||
id: 202509220958
|
||||
author: fyb
|
||||
changes:
|
||||
- sqlFile:
|
||||
encoding: utf8
|
||||
path: classpath:db/changelog/202509220958.sql
|
||||
|
||||
@@ -134,4 +134,5 @@
|
||||
10123=您的mqtt密钥长度不安全,字符数需要至少8个字符且必须同时包含大小写字母
|
||||
10124=您的mqtt密钥长度不安全,mqtt密钥必须同时包含大小写字母
|
||||
10125=您的mqtt密钥包含弱密码
|
||||
10128=字典标签重复
|
||||
10128=字典标签重复
|
||||
10129=modelType和provideCode不能为空
|
||||
@@ -136,4 +136,5 @@
|
||||
10125=Your MQTT secret contains weak password
|
||||
10128=Dictionary label is duplicated
|
||||
10129=SM2 key not configured
|
||||
10130=SM2 decryption failed
|
||||
10130=SM2 decryption failed
|
||||
10131=modelType and provideCode cannot be empty
|
||||
@@ -136,4 +136,5 @@
|
||||
10125=您的mqtt密钥包含弱密码
|
||||
10128=字典标签重复
|
||||
10129=SM2密钥未配置
|
||||
10130=SM2解密失败
|
||||
10130=SM2解密失败
|
||||
10131=modelType和provideCode不能为空
|
||||
@@ -136,4 +136,5 @@
|
||||
10125=您的MQTT密鑰包含弱密碼
|
||||
10128=字典標籤重複
|
||||
10129=SM2密鑰未配置
|
||||
10130=SM2解密失敗
|
||||
10130=SM2解密失敗
|
||||
10131=modelType和provideCode不能為空
|
||||
Reference in New Issue
Block a user