Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -158,8 +158,25 @@ MAX_SUB_DIMS = max(len(d['sub_dims']) for d in DIMENSIONS_DATA)
|
|
| 158 |
# ==============================================================================
|
| 159 |
# 功能函数定义 (Function Definitions)
|
| 160 |
# ==============================================================================
|
| 161 |
-
def start_challenge():
|
| 162 |
-
return gr.update(visible=False), gr.update(visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
|
| 164 |
def toggle_education_other(choice):
|
| 165 |
is_other = (choice == "其他(请注明)")
|
|
@@ -527,7 +544,13 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
|
|
| 527 |
|
| 528 |
full_outputs_with_results = test_init_outputs + [test_results, result_text]
|
| 529 |
|
| 530 |
-
start_btn.click(fn=start_challenge, outputs=[welcome_page, info_page])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 531 |
|
| 532 |
for comp in [age_input, gender_input, education_input, education_other_input, ai_experience_input]:
|
| 533 |
comp.change(
|
|
|
|
| 158 |
# ==============================================================================
|
| 159 |
# 功能函数定义 (Function Definitions)
|
| 160 |
# ==============================================================================
|
| 161 |
+
"""def start_challenge():
|
| 162 |
+
return gr.update(visible=False), gr.update(visible=True)"""
|
| 163 |
+
|
| 164 |
+
def start_challenge(user_data_state):
|
| 165 |
+
global QUESTION_SET, updated_count_data
|
| 166 |
+
|
| 167 |
+
# 每次点击“开始挑战”时重新抽题
|
| 168 |
+
count_data = load_or_initialize_count_json(all_data_audio_paths)
|
| 169 |
+
selected_audio_paths, updated_count_data = sample_audio_paths(all_data_audio_paths, count_data, k=5)
|
| 170 |
+
|
| 171 |
+
QUESTION_SET = [
|
| 172 |
+
{"audio": path, "desc": f"这是音频文件 {os.path.basename(path)} 的描述"}
|
| 173 |
+
for path in selected_audio_paths
|
| 174 |
+
]
|
| 175 |
+
|
| 176 |
+
# 重置 user_data 中的状态(也可以留空)
|
| 177 |
+
user_data_state.clear()
|
| 178 |
+
return gr.update(visible=False), gr.update(visible=True), user_data_state
|
| 179 |
+
|
| 180 |
|
| 181 |
def toggle_education_other(choice):
|
| 182 |
is_other = (choice == "其他(请注明)")
|
|
|
|
| 544 |
|
| 545 |
full_outputs_with_results = test_init_outputs + [test_results, result_text]
|
| 546 |
|
| 547 |
+
# start_btn.click(fn=start_challenge, outputs=[welcome_page, info_page])
|
| 548 |
+
start_btn.click(
|
| 549 |
+
fn=start_challenge,
|
| 550 |
+
inputs=[user_data_state],
|
| 551 |
+
outputs=[welcome_page, info_page, user_data_state]
|
| 552 |
+
)
|
| 553 |
+
|
| 554 |
|
| 555 |
for comp in [age_input, gender_input, education_input, education_other_input, ai_experience_input]:
|
| 556 |
comp.change(
|