Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -98,7 +98,6 @@ def load_or_initialize_count_json(audio_paths):
|
|
| 98 |
count_data = collections.OrderedDict()
|
| 99 |
|
| 100 |
updated = False
|
| 101 |
-
|
| 102 |
for path in audio_paths:
|
| 103 |
filename = os.path.basename(path)
|
| 104 |
if filename not in count_data:
|
|
@@ -311,6 +310,7 @@ def submit_question_and_advance(q_idx, d_idx, selections, final_choice, all_resu
|
|
| 311 |
else:
|
| 312 |
result_str = "### 测试全部完成!\n\n你的提交结果概览:\n"
|
| 313 |
for res in all_results:
|
|
|
|
| 314 |
result_str += f"##### 最终判断: **{res['selections'].get('final_choice', '未选择')}**\n"
|
| 315 |
for dim_title, dim_data in res['selections'].items():
|
| 316 |
if dim_title == 'final_choice': continue
|
|
@@ -318,6 +318,7 @@ def submit_question_and_advance(q_idx, d_idx, selections, final_choice, all_resu
|
|
| 318 |
for sub_dim, score in dim_data.items():
|
| 319 |
result_str += f" - *{sub_dim[:20]}...*: {score}/5\n"
|
| 320 |
|
|
|
|
| 321 |
save_all_results_to_file(all_results, user_data, count_data=updated_count_data)
|
| 322 |
|
| 323 |
return (
|
|
@@ -326,7 +327,7 @@ def submit_question_and_advance(q_idx, d_idx, selections, final_choice, all_resu
|
|
| 326 |
gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),
|
| 327 |
gr.update(), gr.update(),
|
| 328 |
) + (gr.update(),) * MAX_SUB_DIMS + (all_results, result_str)
|
| 329 |
-
|
| 330 |
def save_all_results_to_file(all_results, user_data, count_data=None):
|
| 331 |
repo_id = "intersteller2887/Turing-test-dataset"
|
| 332 |
username = user_data.get("username", "user")
|
|
@@ -577,6 +578,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
|
|
| 577 |
)
|
| 578 |
|
| 579 |
back_to_welcome_btn.click(fn=back_to_welcome, outputs=list(pages.values()) + [user_data_state, current_question_index, current_test_dimension_index, current_question_selections, test_results])
|
|
|
|
| 580 |
# ==============================================================================
|
| 581 |
# 程序入口 (Entry Point)
|
| 582 |
# ==============================================================================
|
|
|
|
| 98 |
count_data = collections.OrderedDict()
|
| 99 |
|
| 100 |
updated = False
|
|
|
|
| 101 |
for path in audio_paths:
|
| 102 |
filename = os.path.basename(path)
|
| 103 |
if filename not in count_data:
|
|
|
|
| 310 |
else:
|
| 311 |
result_str = "### 测试全部完成!\n\n你的提交结果概览:\n"
|
| 312 |
for res in all_results:
|
| 313 |
+
# result_str += f"\n#### 题目: {res['audio_file']}\n"
|
| 314 |
result_str += f"##### 最终判断: **{res['selections'].get('final_choice', '未选择')}**\n"
|
| 315 |
for dim_title, dim_data in res['selections'].items():
|
| 316 |
if dim_title == 'final_choice': continue
|
|
|
|
| 318 |
for sub_dim, score in dim_data.items():
|
| 319 |
result_str += f" - *{sub_dim[:20]}...*: {score}/5\n"
|
| 320 |
|
| 321 |
+
# save_all_results_to_file(all_results, user_data)
|
| 322 |
save_all_results_to_file(all_results, user_data, count_data=updated_count_data)
|
| 323 |
|
| 324 |
return (
|
|
|
|
| 327 |
gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),
|
| 328 |
gr.update(), gr.update(),
|
| 329 |
) + (gr.update(),) * MAX_SUB_DIMS + (all_results, result_str)
|
| 330 |
+
|
| 331 |
def save_all_results_to_file(all_results, user_data, count_data=None):
|
| 332 |
repo_id = "intersteller2887/Turing-test-dataset"
|
| 333 |
username = user_data.get("username", "user")
|
|
|
|
| 578 |
)
|
| 579 |
|
| 580 |
back_to_welcome_btn.click(fn=back_to_welcome, outputs=list(pages.values()) + [user_data_state, current_question_index, current_test_dimension_index, current_question_selections, test_results])
|
| 581 |
+
|
| 582 |
# ==============================================================================
|
| 583 |
# 程序入口 (Entry Point)
|
| 584 |
# ==============================================================================
|