Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -99,17 +99,10 @@ def load_or_initialize_count_json(audio_paths):
|
|
99 |
|
100 |
updated = False
|
101 |
|
102 |
-
# 获取所有样例音频文件名
|
103 |
-
sample_audio_files = {os.path.basename(d["audio"]) for d in DIMENSIONS_DATA}
|
104 |
-
|
105 |
for path in audio_paths:
|
106 |
filename = os.path.basename(path)
|
107 |
if filename not in count_data:
|
108 |
-
|
109 |
-
if filename in sample_audio_files:
|
110 |
-
count_data[filename] = 999 # 设置为很大的值,确保不会被选中
|
111 |
-
else:
|
112 |
-
count_data[filename] = 0
|
113 |
updated = True
|
114 |
|
115 |
if updated or not os.path.exists(COUNT_JSON_PATH):
|
@@ -314,10 +307,7 @@ def submit_question_and_advance(q_idx, d_idx, selections, final_choice, all_resu
|
|
314 |
|
315 |
if q_idx < len(QUESTION_SET):
|
316 |
init_q_updates = init_test_question(user_data, q_idx)
|
317 |
-
|
318 |
-
init_q_updates = list(init_q_updates)
|
319 |
-
init_q_updates[9] = None # test_audio 的位置设为 None 来停止播放
|
320 |
-
return tuple(init_q_updates) + (all_results, gr.update(value=""))
|
321 |
else:
|
322 |
result_str = "### 测试全部完成!\n\n你的提交结果概览:\n"
|
323 |
for res in all_results:
|
@@ -333,10 +323,10 @@ def submit_question_and_advance(q_idx, d_idx, selections, final_choice, all_resu
|
|
333 |
return (
|
334 |
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True),
|
335 |
q_idx, d_idx, {},
|
336 |
-
gr.update(), gr.update(),
|
337 |
gr.update(), gr.update(),
|
338 |
) + (gr.update(),) * MAX_SUB_DIMS + (all_results, result_str)
|
339 |
-
|
340 |
def save_all_results_to_file(all_results, user_data, count_data=None):
|
341 |
repo_id = "intersteller2887/Turing-test-dataset"
|
342 |
username = user_data.get("username", "user")
|
@@ -406,8 +396,7 @@ def back_to_welcome():
|
|
406 |
0, # current_question_index
|
407 |
0, # current_test_dimension_index
|
408 |
{}, # current_question_selections
|
409 |
-
[]
|
410 |
-
None # 停止音频
|
411 |
)
|
412 |
|
413 |
# ==============================================================================
|
@@ -587,10 +576,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
|
|
587 |
outputs=full_outputs_with_results
|
588 |
)
|
589 |
|
590 |
-
back_to_welcome_btn.click(
|
591 |
-
fn=back_to_welcome,
|
592 |
-
outputs=list(pages.values()) + [user_data_state, current_question_index, current_test_dimension_index, current_question_selections, test_results, test_audio]
|
593 |
-
)
|
594 |
# ==============================================================================
|
595 |
# 程序入口 (Entry Point)
|
596 |
# ==============================================================================
|
|
|
99 |
|
100 |
updated = False
|
101 |
|
|
|
|
|
|
|
102 |
for path in audio_paths:
|
103 |
filename = os.path.basename(path)
|
104 |
if filename not in count_data:
|
105 |
+
count_data[filename] = 0
|
|
|
|
|
|
|
|
|
106 |
updated = True
|
107 |
|
108 |
if updated or not os.path.exists(COUNT_JSON_PATH):
|
|
|
307 |
|
308 |
if q_idx < len(QUESTION_SET):
|
309 |
init_q_updates = init_test_question(user_data, q_idx)
|
310 |
+
return init_q_updates + (all_results, gr.update(value=""))
|
|
|
|
|
|
|
311 |
else:
|
312 |
result_str = "### 测试全部完成!\n\n你的提交结果概览:\n"
|
313 |
for res in all_results:
|
|
|
323 |
return (
|
324 |
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True),
|
325 |
q_idx, d_idx, {},
|
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")
|
|
|
396 |
0, # current_question_index
|
397 |
0, # current_test_dimension_index
|
398 |
{}, # current_question_selections
|
399 |
+
[] # test_results
|
|
|
400 |
)
|
401 |
|
402 |
# ==============================================================================
|
|
|
576 |
outputs=full_outputs_with_results
|
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 |
# ==============================================================================
|