mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
声纹识别功能开关
This commit is contained in:
@@ -141,6 +141,7 @@ plugins:
|
||||
|
||||
# 声纹识别配置
|
||||
voiceprint:
|
||||
enable: false
|
||||
# 声纹接口地址
|
||||
url:
|
||||
# 说话人配置:speaker_id,名称,描述
|
||||
|
||||
@@ -430,12 +430,16 @@ class ConnectionHandler:
|
||||
def _initialize_voiceprint(self):
|
||||
"""为当前连接初始化声纹识别"""
|
||||
try:
|
||||
voiceprint_config = self.config.get("voiceprint", {})
|
||||
if voiceprint_config:
|
||||
self.voiceprint_provider = VoiceprintProvider(voiceprint_config)
|
||||
self.logger.bind(tag=TAG).info("声纹识别功能已在连接时动态启用")
|
||||
voiceprint_enable = self.config.get("voiceprint", {}).get("enable", False)
|
||||
if voiceprint_enable:
|
||||
voiceprint_provider = VoiceprintProvider(self.config.get("voiceprint", {}))
|
||||
if voiceprint_provider is not None and voiceprint_provider.enabled:
|
||||
self.voiceprint_provider = voiceprint_provider
|
||||
self.logger.bind(tag=TAG).info("声纹识别功能已在连接时动态启用")
|
||||
else:
|
||||
self.logger.bind(tag=TAG).warning("声纹识别功能启用但配置不完整")
|
||||
else:
|
||||
self.logger.bind(tag=TAG).info("声纹识别功能未启用或配置不完整")
|
||||
self.logger.bind(tag=TAG).info("声纹识别功能未启用")
|
||||
except Exception as e:
|
||||
self.logger.bind(tag=TAG).warning(f"声纹识别初始化失败: {str(e)}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user