'commit'
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -66,12 +66,21 @@ async def save_audio(audio: UploadFile = File(...), txt: str = Form(...)):
|
|||||||
appid=XF_APPID,
|
appid=XF_APPID,
|
||||||
api_key=XF_APIKEY,
|
api_key=XF_APIKEY,
|
||||||
api_secret=XF_APISECRET,
|
api_secret=XF_APISECRET,
|
||||||
audio_file=mp3_file_path, # 使用新的MP3路径
|
audio_file=mp3_file_path, # 使用MP3文件路径
|
||||||
txt=txt
|
txt=txt.strip() # 确保文本预处理,避免None
|
||||||
)
|
)
|
||||||
results, eval_time = evaluator.run_evaluation()
|
|
||||||
print(evaluator.get_evaluation_summary())
|
|
||||||
|
|
||||||
|
# 运行评测并获取结果(已整合重构后的解析逻辑)
|
||||||
|
results, eval_time = evaluator.run_evaluation()
|
||||||
|
|
||||||
|
# 验证解析结果完整性
|
||||||
|
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 {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
|
Binary file not shown.
Binary file not shown.
@@ -116,10 +116,6 @@
|
|||||||
<span class="score-value" id="totalScore">--</span>
|
<span class="score-value" id="totalScore">--</span>
|
||||||
<span class="score-label">总分</span>
|
<span class="score-label">总分</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="score-item">
|
|
||||||
<span class="score-value" id="accuracyScore">--</span>
|
|
||||||
<span class="score-label">准确度</span>
|
|
||||||
</div>
|
|
||||||
<div class="score-item">
|
<div class="score-item">
|
||||||
<span class="score-value" id="fluencyScore">--</span>
|
<span class="score-value" id="fluencyScore">--</span>
|
||||||
<span class="score-label">流利度</span>
|
<span class="score-label">流利度</span>
|
||||||
@@ -128,10 +124,15 @@
|
|||||||
<span class="score-value" id="completenessScore">--</span>
|
<span class="score-value" id="completenessScore">--</span>
|
||||||
<span class="score-label">完整度</span>
|
<span class="score-label">完整度</span>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 新增评分项 -->
|
||||||
|
<div class="score-item">
|
||||||
|
<span class="score-value" id="toneScore">--</span>
|
||||||
|
<span class="score-label">语调</span>
|
||||||
|
</div>
|
||||||
|
<div class="score-item">
|
||||||
|
<span class="score-value" id="phoneScore">--</span>
|
||||||
|
<span class="score-label">发音</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="words-list" id="wordsList">
|
|
||||||
<h4 style="color: #5eead4; margin-bottom: 10px;">字词评分</h4>
|
|
||||||
<div id="wordsContent">等待评测结果...</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -174,11 +175,15 @@
|
|||||||
this.progressText = document.getElementById('progressText');
|
this.progressText = document.getElementById('progressText');
|
||||||
this.evaluationContainer = document.getElementById('evaluationContainer');
|
this.evaluationContainer = document.getElementById('evaluationContainer');
|
||||||
this.totalScore = document.getElementById('totalScore');
|
this.totalScore = document.getElementById('totalScore');
|
||||||
this.accuracyScore = document.getElementById('accuracyScore');
|
// 移除已删除的准确度评分元素引用
|
||||||
this.fluencyScore = document.getElementById('fluencyScore');
|
this.fluencyScore = document.getElementById('fluencyScore');
|
||||||
this.completenessScore = document.getElementById('completenessScore');
|
this.completenessScore = document.getElementById('completenessScore');
|
||||||
this.wordsList = document.getElementById('wordsList');
|
this.toneScore = document.getElementById('toneScore');
|
||||||
this.wordsContent = document.getElementById('wordsContent');
|
this.phoneScore = document.getElementById('phoneScore');
|
||||||
|
// 移除已删除的情感评分元素引用
|
||||||
|
//this.emotionScore = document.getElementById('emotionScore');
|
||||||
|
//this.wordsList = document.getElementById('wordsList');
|
||||||
|
//this.wordsContent = document.getElementById('wordsContent');
|
||||||
}
|
}
|
||||||
|
|
||||||
setupCanvas() {
|
setupCanvas() {
|
||||||
@@ -397,31 +402,34 @@
|
|||||||
displayEvaluationResults(evaluation) {
|
displayEvaluationResults(evaluation) {
|
||||||
if (!evaluation) return;
|
if (!evaluation) return;
|
||||||
|
|
||||||
// 显示评分卡片
|
|
||||||
this.totalScore.textContent = evaluation.total_score ? evaluation.total_score.toFixed(1) : '--';
|
this.totalScore.textContent = evaluation.total_score ? evaluation.total_score.toFixed(1) : '--';
|
||||||
this.accuracyScore.textContent = evaluation.accuracy_score ? evaluation.accuracy_score.toFixed(1) : '--';
|
// 移除已删除的准确度评分设置
|
||||||
this.fluencyScore.textContent = evaluation.fluency_score ? evaluation.fluency_score.toFixed(1) : '--';
|
this.fluencyScore.textContent = evaluation.fluency_score ? evaluation.fluency_score.toFixed(1) : '--';
|
||||||
this.completenessScore.textContent = evaluation.completeness_score ? evaluation.completeness_score.toFixed(1) : '--';
|
this.completenessScore.textContent = evaluation.integrity_score ? evaluation.integrity_score.toFixed(1) : '--';
|
||||||
|
this.toneScore.textContent = evaluation.tone_score ? evaluation.tone_score.toFixed(1) : '--';
|
||||||
|
this.phoneScore.textContent = evaluation.phone_score ? evaluation.phone_score.toFixed(1) : '--';
|
||||||
|
// 移除已删除的情感评分设置
|
||||||
|
|
||||||
this.evaluationContainer.classList.add('show');
|
this.evaluationContainer.classList.add('show');
|
||||||
|
|
||||||
// 显示字词评分
|
// // 移除已删除的句子评分相关代码
|
||||||
if (evaluation.words && evaluation.words.length > 0) {
|
// const sentencesContent = document.getElementById('sentencesContent');
|
||||||
let wordsHTML = '';
|
// if (evaluation.sentences && evaluation.sentences.length > 0) {
|
||||||
evaluation.words.forEach((word, index) => {
|
// let sentencesHTML = '';
|
||||||
const score = word.total_score ? word.total_score.toFixed(1) : '0.0';
|
// evaluation.sentences.forEach((sentence, index) => {
|
||||||
const color = score >= 80 ? '#10b981' : score >= 60 ? '#f59e0b' : '#ef4444';
|
// const score = sentence.total_score ? sentence.total_score.toFixed(1) : '--';
|
||||||
wordsHTML += `
|
// const color = score >= 90 ? '#5eead4' : score >= 80 ? '#a7f3d0' : '#fef3c7';
|
||||||
<div class="word-item">
|
// sentencesHTML += `
|
||||||
<span class="word-content">${word.content || `字词${index + 1}`}</span>
|
// <div style="display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(148, 163, 184, 0.1);">
|
||||||
<span class="word-score" style="color: ${color}">${score}</span>
|
// <span style="color: #e2e8f0;">${index + 1}. ${sentence.content}</span>
|
||||||
</div>
|
// <span style="font-weight: bold; color: ${color};">${score}</span>
|
||||||
`;
|
// </div>
|
||||||
});
|
// `;
|
||||||
this.wordsContent.innerHTML = wordsHTML;
|
// });
|
||||||
} else {
|
// sentencesContent.innerHTML = sentencesHTML;
|
||||||
this.wordsContent.innerHTML = '<p style="color: #cbd5e1; text-align: center;">无字词评分数据</p>';
|
// } else {
|
||||||
}
|
// sentencesContent.innerHTML = '<p style="color: #94a3b8; text-align: center;">无句子评分数据</p>';
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
simulateUploadProgress() {
|
simulateUploadProgress() {
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user