增加控制台配置,调整部分逻辑

This commit is contained in:
Sakura-RanChen 2026-10-26 11:40:00 +08:00
parent 9880ce998f
commit 1120be2f60
4 changed files with 17 additions and 8 deletions

View file

@ -0,0 +1,4 @@
-- 添加MCP接入点附带说话人身份的开关参数配置
delete from `sys_params` where param_code = 'mcp_forward_speaker';
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark)
VALUES (313, 'mcp_forward_speaker', 'true', 'boolean', 1, '是否随MCP调用附带说话人身份');

View file

@ -753,3 +753,10 @@ databaseChangeLog:
- sqlFile:
encoding: utf8
path: classpath:db/changelog/202609172100.sql
- changeSet:
id: 202610261030
author: RanChen
changes:
- sqlFile:
encoding: utf8
path: classpath:db/changelog/202610261030.sql

View file

@ -120,14 +120,12 @@ class ASRProviderBase(ABC):
raw_text, _ = asr_result
speaker_id = None
speaker_name = ""
if isinstance(voiceprint_result, Exception):
logger.bind(tag=TAG).error(f"声纹识别失败: {voiceprint_result}")
speaker_name = ""
elif voiceprint_result is not None:
speaker_name = voiceprint_result.name or ""
speaker_id = voiceprint_result.speaker_id
else:
speaker_name = ""
# 判断 ASR 结果类型
if isinstance(raw_text, dict):

View file

@ -19,7 +19,7 @@ class SpeakerIdentification(NamedTuple):
"""一次声纹识别结果。speaker_id 仅在命中已配置说话人时有值。"""
speaker_id: Optional[str]
name: Optional[str]
name: str
def resolve_speaker_identification(
@ -204,13 +204,13 @@ class VoiceprintProvider:
identified = resolve_speaker_identification(
speaker_id, score, self.speaker_map, self.similarity_threshold
)
# 相似度阈值检查
if score < self.similarity_threshold:
logger.bind(tag=TAG).warning(f"声纹识别相似度{score:.3f}低于阈值{self.similarity_threshold}")
elif identified.speaker_id:
# 三种结果:命中 / 低于阈值 / id不在配置中
if identified.speaker_id:
logger.bind(tag=TAG).info(
f"声纹识别成功: {identified.name} (id: {identified.speaker_id}, 相似度: {score:.3f})"
)
elif score < self.similarity_threshold:
logger.bind(tag=TAG).warning(f"声纹识别相似度{score:.3f}低于阈值{self.similarity_threshold}")
else:
logger.bind(tag=TAG).warning(f"未识别的说话人ID: {speaker_id}")
return identified