from src.utils.logger import get_module_logger, setup_root_logger
from tests.modelsuse import vad_model_use_online_logic, asr_model_use_offline
import json
setup_root_logger(level="INFO",log_file="logs/test_main.log")

logger = get_module_logger(__name__)

logger.info("开始测试")
vad_result = vad_model_use_online_logic("tests/vad_example.wav")
logger.info("测试结束")
if vad_result is None:
    logger.warning("VAD结果为空")
else:
    logger.info(f"VAD结果: {vad_result}")

asr_result = asr_model_use_offline("tests/vad_example.wav")
# asr_result str->dict
setup_root_logger(level="INFO",log_file="logs/test_main.log")
result = asr_result[0]['sentence_info']
for item in result:
    #[{'start': 70, 'end': 2340, 'sentence': '试 错 的 过 程 很 简 单', 'timestamp': [[380, 620], [640, 740], [740, 940], [940, 1020], [1020, 1260], [1500, 1740], [1740, 1840], [1840, 2135]], 'spk': 0}
    logger.info(f"spk[{item['spk']}] [{item['start']}ms:{item['end']}ms] {item['sentence'].replace(' ', '')}")