28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
import os
|
|
from XunFeiAudioEvaluator_cn import XunFeiAudioEvaluator_cn
|
|
import xml.etree.ElementTree as ET
|
|
|
|
if __name__ == "__main__":
|
|
log_path = r"1.xml"
|
|
evaluator = XunFeiAudioEvaluator_cn(None, None, None, None, "") # 使用空字符串代替None作为txt参数
|
|
|
|
if os.path.exists(log_path):
|
|
try:
|
|
# 读取XML文件内容
|
|
with open(log_path, 'r', encoding='utf-8') as f:
|
|
xml_content = f.read()
|
|
|
|
# 使用XunFeiAudioEvaluator_cn类的解析方法
|
|
evaluator.parse_evaluation_results(xml_content)
|
|
results = evaluator.evaluation_results
|
|
|
|
if results and 'total_score' in results:
|
|
print("解析成功!以下是评分数据:")
|
|
for key, value in results.items():
|
|
print(f"{key}: {value}")
|
|
else:
|
|
print("未找到有效的评分数据")
|
|
except Exception as e:
|
|
print(f"解析日志时出错:{str(e)}")
|
|
else:
|
|
print(f"文件不存在:{log_path}") |