This commit is contained in:
2025-09-06 10:47:32 +08:00
parent 4ed874ba4b
commit b7c7dd1766
6 changed files with 16 additions and 17 deletions

View File

@@ -105,21 +105,20 @@ class XunFeiAudioEvaluator_cn:
"app_id": self.appid
},
"business": {
"category": "read_sentence",
"category": "read_chapter",
"rstcd": "utf8",
"sub": "ise",
"group": "pupil", # 根据文档设置为小学组
"group": "adult", # 根据文档设置为小学组
"ent": "cn_vip", # 固定中文引擎
"tte": "utf-8",
"cmd": "ssb",
"auf": "audio/L16;rate=16000", # 修复参数格式错误
"aue": "lame",
#"auf": "audio/L16;rate=16000", # 修复参数格式错误
"aue": "lame",# mp3
"text": '\uFEFF' + "[content]\n" + self.txt, # 确保UTF8 BOM
"extra_ability": "multi_dimension" # 启用多维度评分
},
"data": {
"status": 0,
"data": ""
}
}
ws.send(json.dumps(send_dict))
@@ -169,21 +168,21 @@ class XunFeiAudioEvaluator_cn:
"""解析中文评测XML结果仅处理read_sentence节点"""
try:
root = ET.fromstring(xml_content)
# 中文专用:查找read_sentence节点
read_sentence = root.find('.//read_sentence')
if read_sentence is not None:
# 中文评分字段映射
# 中文专用查找read_chapter节点原read_sentence
read_chapter = root.find('.//read_chapter')
if read_chapter is not None:
# 中文评分字段映射(修正节点名称和属性)
self.evaluation_results = {
'total_score': float(read_sentence.get('total_score', 0)),
'accuracy_score': float(read_sentence.get('accuracy_score', 0)),
'fluency_score': float(read_sentence.get('fluency_score', 0)),
'integrity_score': float(read_sentence.get('integrity_score', 0)),
'tone_score': float(read_sentence.get('tone_score', 0)), # 中文特有调型分
'is_rejected': read_sentence.get('is_rejected', 'false') == 'true'
'total_score': float(read_chapter.get('total_score', 0)),
'accuracy_score': float(read_chapter.get('accuracy_score', 0)),
'fluency_score': float(read_chapter.get('fluency_score', 0)),
'integrity_score': float(read_chapter.get('integrity_score', 0)), # 修正字段名
'tone_score': float(read_chapter.get('tone_score', 0)),
'is_rejected': read_chapter.get('is_rejected', 'false') == 'true'
}
# 提取句子级得分(中文特有)
# 提取句子级得分
sentences = []
for sent in read_sentence.findall('.//sentence'):
for sent in read_chapter.findall('.//sentence'):
sentences.append({
'content': sent.get('content', ''),
'total_score': float(sent.get('total_score', 0)),