'commit'
This commit is contained in:
@@ -66,12 +66,21 @@ async def save_audio(audio: UploadFile = File(...), txt: str = Form(...)):
|
||||
appid=XF_APPID,
|
||||
api_key=XF_APIKEY,
|
||||
api_secret=XF_APISECRET,
|
||||
audio_file=mp3_file_path, # 使用新的MP3路径
|
||||
txt=txt
|
||||
audio_file=mp3_file_path, # 使用MP3文件路径
|
||||
txt=txt.strip() # 确保文本预处理,避免None
|
||||
)
|
||||
|
||||
# 运行评测并获取结果(已整合重构后的解析逻辑)
|
||||
results, eval_time = evaluator.run_evaluation()
|
||||
print(evaluator.get_evaluation_summary())
|
||||
|
||||
|
||||
# 验证解析结果完整性
|
||||
if not results or 'total_score' not in results:
|
||||
# 尝试从本地XML文件重新解析(容错机制)
|
||||
xml_log_path = os.path.join(UPLOAD_DIR, f"{os.path.splitext(mp3_file_name)[0]}.xml")
|
||||
if os.path.exists(xml_log_path):
|
||||
with open(xml_log_path, 'r', encoding='utf-8') as f:
|
||||
evaluator.parse_evaluation_results(f.read())
|
||||
results = evaluator.evaluation_results
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
|
Reference in New Issue
Block a user