mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-25 08:33:53 +08:00
update:优化日志对象
This commit is contained in:
@@ -350,12 +350,6 @@ def initialize_modules(
|
||||
str(config.get("delete_audio", True)).lower() in ("true", "1", "yes"),
|
||||
)
|
||||
logger.bind(tag=TAG).info(f"初始化组件: asr成功 {select_asr_module}")
|
||||
|
||||
# 初始化自定义prompt
|
||||
if config.get("prompt", None) is not None:
|
||||
modules["prompt"] = config["prompt"]
|
||||
logger.bind(tag=TAG).info(f"初始化组件: prompt成功 {modules['prompt'][:50]}...")
|
||||
|
||||
return modules
|
||||
|
||||
|
||||
@@ -913,3 +907,45 @@ def audio_to_opus_data(audio_file_path):
|
||||
opus_datas.append(opus_data)
|
||||
|
||||
return opus_datas, duration
|
||||
|
||||
|
||||
def check_vad_update(before_config, new_config):
|
||||
if new_config["selected_module"].get("VAD") is None:
|
||||
return False
|
||||
update_vad = False
|
||||
current_vad_module = before_config["selected_module"]["VAD"]
|
||||
new_vad_module = new_config["selected_module"]["VAD"]
|
||||
current_vad_type = (
|
||||
current_vad_module
|
||||
if "type" not in before_config["VAD"][current_vad_module]
|
||||
else before_config["VAD"][current_vad_module]["type"]
|
||||
)
|
||||
new_vad_type = (
|
||||
new_vad_module
|
||||
if "type" not in new_config["VAD"][new_vad_module]
|
||||
else new_config["VAD"][new_vad_module]["type"]
|
||||
)
|
||||
print(f"前vad:{current_vad_type},后vad:{new_vad_type}")
|
||||
update_vad = current_vad_type != new_vad_type
|
||||
return update_vad
|
||||
|
||||
|
||||
def check_asr_update(before_config, new_config):
|
||||
if new_config["selected_module"].get("ASR") is None:
|
||||
return False
|
||||
update_asr = False
|
||||
current_asr_module = before_config["selected_module"]["ASR"]
|
||||
new_asr_module = new_config["selected_module"]["ASR"]
|
||||
current_asr_type = (
|
||||
current_asr_module
|
||||
if "type" not in before_config["ASR"][current_asr_module]
|
||||
else before_config["ASR"][current_asr_module]["type"]
|
||||
)
|
||||
new_asr_type = (
|
||||
new_asr_module
|
||||
if "type" not in new_config["ASR"][new_asr_module]
|
||||
else new_config["ASR"][new_asr_module]["type"]
|
||||
)
|
||||
print(f"前asr:{current_asr_type},后asr:{new_asr_type}")
|
||||
update_asr = current_asr_type != new_asr_type
|
||||
return update_asr
|
||||
|
||||
Reference in New Issue
Block a user