Spark Chou
commited on
Commit
·
76578a8
1
Parent(s):
5d0ff5c
app.py
CHANGED
@@ -47,62 +47,62 @@ print(sample1_audio_path)
|
|
47 |
|
48 |
DIMENSIONS_DATA = [
|
49 |
{
|
50 |
-
"title": "
|
51 |
-
"audio": sample1_audio_path,
|
52 |
"sub_dims": [
|
53 |
-
"
|
54 |
-
"
|
55 |
-
"
|
56 |
-
"
|
57 |
-
"
|
58 |
-
"
|
59 |
-
"
|
60 |
],
|
61 |
-
"reference_scores": [5, 5,
|
62 |
},
|
63 |
{
|
64 |
-
"title": "
|
65 |
-
"audio": sample1_audio_path,
|
66 |
"sub_dims": [
|
67 |
-
"
|
68 |
-
"
|
69 |
-
"
|
70 |
-
"
|
71 |
],
|
72 |
-
"reference_scores": [
|
73 |
},
|
74 |
{
|
75 |
-
"title": "
|
76 |
-
"audio": sample1_audio_path,
|
77 |
"sub_dims": [
|
78 |
-
"
|
79 |
-
"
|
80 |
-
"
|
81 |
],
|
82 |
-
"reference_scores": [
|
83 |
},
|
84 |
{
|
85 |
-
"title": "
|
86 |
-
"audio": sample1_audio_path,
|
87 |
"sub_dims": [
|
88 |
-
"
|
89 |
-
"
|
90 |
],
|
91 |
"reference_scores": [5, 5]
|
92 |
},
|
93 |
{
|
94 |
-
"title": "
|
95 |
-
"audio": sample1_audio_path,
|
96 |
"sub_dims": [
|
97 |
-
"
|
98 |
-
"
|
99 |
],
|
100 |
-
"reference_scores": [
|
101 |
}
|
102 |
]
|
103 |
|
104 |
DIMENSION_TITLES = [d["title"] for d in DIMENSIONS_DATA]
|
105 |
-
SPECIAL_KEYWORDS = ["
|
106 |
MAX_SUB_DIMS = max(len(d['sub_dims']) for d in DIMENSIONS_DATA)
|
107 |
THE_SUB_DIMS = [d['sub_dims'] for d in DIMENSIONS_DATA]
|
108 |
|
@@ -371,13 +371,13 @@ def update_test_dimension_view(d_idx, selections):
|
|
371 |
sub_dims = dim_data["sub_dims"]
|
372 |
dim_title = dim_data["title"]
|
373 |
existing_scores = selections.get(dim_data['title'], {})
|
374 |
-
progress_d = f"
|
375 |
|
376 |
for i in range(MAX_SUB_DIMS):
|
377 |
if i < len(sub_dims):
|
378 |
desc = sub_dims[i]
|
379 |
# print(f"{desc} -> default value: {existing_scores.get(desc, 0)}")
|
380 |
-
name = desc.split("
|
381 |
default_value = 0 if name in SPECIAL_KEYWORDS else 1
|
382 |
value = existing_scores.get(desc, default_value)
|
383 |
|
@@ -400,7 +400,7 @@ def update_test_dimension_view(d_idx, selections):
|
|
400 |
# ))
|
401 |
else:
|
402 |
slider_updates.append(gr.update(visible=False))
|
403 |
-
print(f"{desc} -> default value: {existing_scores.get(desc, 0)}")
|
404 |
# for i in range(MAX_SUB_DIMS):
|
405 |
# if i < len(dimension['sub_dims']):
|
406 |
# sub_dim_label = dimension['sub_dims'][i]
|
@@ -411,7 +411,7 @@ def update_test_dimension_view(d_idx, selections):
|
|
411 |
|
412 |
prev_btn_update = gr.update(interactive=(d_idx > 0))
|
413 |
next_btn_update = gr.update(
|
414 |
-
value="
|
415 |
interactive=True
|
416 |
)
|
417 |
|
@@ -420,7 +420,7 @@ def update_test_dimension_view(d_idx, selections):
|
|
420 |
def init_test_question(user_data, q_idx):
|
421 |
d_idx = 0
|
422 |
question = user_data["question_set"][q_idx]
|
423 |
-
progress_q = f"
|
424 |
|
425 |
initial_updates = update_test_dimension_view(d_idx, {})
|
426 |
dim_title_update, prev_btn_update, next_btn_update = initial_updates[:3]
|
@@ -664,9 +664,9 @@ def submit_question_and_advance(q_idx, d_idx, selections, final_choice, all_resu
|
|
664 |
return init_q_updates + (all_results, gr.update(value=""))
|
665 |
else:
|
666 |
# 准备完整结果数据
|
667 |
-
result_str = "###
|
668 |
for res in all_results:
|
669 |
-
result_str += f"#####
|
670 |
for dim_title, dim_data in res['selections'].items():
|
671 |
if dim_title == 'final_choice': continue
|
672 |
result_str += f"- **{dim_title}**:\n"
|
@@ -858,8 +858,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
|
|
858 |
}
|
859 |
|
860 |
with welcome_page:
|
861 |
-
gr.Markdown("# AI
|
862 |
-
start_btn = gr.Button("
|
863 |
|
864 |
with info_page:
|
865 |
gr.Markdown("## 请提供一些基本信息")
|
|
|
47 |
|
48 |
DIMENSIONS_DATA = [
|
49 |
{
|
50 |
+
"title": "Semantic and Pragmatic Features",
|
51 |
+
"audio": "sample1_audio_path",
|
52 |
"sub_dims": [
|
53 |
+
"Memory Consistency: Human memory in short contexts is usually consistent and self-correcting (e.g., by asking questions); machines may show inconsistent context memory and fail to notice or correct errors (e.g., forgetting key information and persisting in wrong answers).",
|
54 |
+
"Logical Coherence: Human logic is naturally coherent and allows reasonable leaps; machine logic is abrupt or self-contradictory (e.g., sudden topic shifts without transitions).",
|
55 |
+
"Pronunciation Accuracy: Human-like: Correct and natural pronunciation of words, including context-appropriate usage of common English heteronyms; Machine-like: Unnatural pronunciation errors, especially mispronunciation of common heteronyms",
|
56 |
+
"Code-switching: Humans mix multiple languages fluently and contextually; machines mix languages rigidly, lacking logical language switching.",
|
57 |
+
"Linguistic Vagueness: Human speech tends to include vague expressions (e.g., “more or less,” “I guess”) and self-corrections; machine responses are typically precise and assertive.",
|
58 |
+
"Filler Word Usage: Human filler words (e.g., 'uh', 'like') appear randomly and show signs of thinking; machine fillers are either repetitive and patterned or completely absent.",
|
59 |
+
"Metaphor and Pragmatic Intent: Humans use metaphors, irony, and euphemisms to express layered meanings; machines interpret literally or use rhetorical devices awkwardly, lacking semantic richness."
|
60 |
],
|
61 |
+
"reference_scores": [5, 5, 3, 3, 5, 5, 3]
|
62 |
},
|
63 |
{
|
64 |
+
"title": "Non-Physiological Paralinguistic Features",
|
65 |
+
"audio": "sample1_audio_path",
|
66 |
"sub_dims": [
|
67 |
+
"Rhythm: Human speech rate varies with meaning, occasionally hesitating or pausing; machine rhythm is uniform, with little or mechanical pauses.",
|
68 |
+
"Intonation: Humans naturally raise or lower pitch to express questions, surprise, or emphasis; machine intonation is monotonous or overly patterned, mismatching the context.",
|
69 |
+
"Emphasis: Humans consciously stress key words to highlight important information; machines have uniform word emphasis or stress incorrect parts.",
|
70 |
+
"Auxiliary Vocalizations: Humans produce context-appropriate non-verbal sounds (e.g., laughter, sighs); machine non-verbal sounds are contextually incorrect, mechanical, or absent."
|
71 |
],
|
72 |
+
"reference_scores": [4, 5, 4, 3]
|
73 |
},
|
74 |
{
|
75 |
+
"title": "Physiological Paralinguistic Features",
|
76 |
+
"audio": "sample1_audio_path",
|
77 |
"sub_dims": [
|
78 |
+
"Micro-physiological Noise: Human speech includes unconscious physiological sounds like breathing, saliva, or bubbling, naturally woven into rhythm; machine speech is overly clean or adds unnatural noises.",
|
79 |
+
"Pronunciation Instability: Human pronunciation includes irregularities (e.g., linking, tremors, slurring, nasal sounds); machine pronunciation is overly standard and uniform, lacking personality.",
|
80 |
+
"Accent: Humans naturally exhibit regional accents or speech traits; machine accents sound forced or unnatural."
|
81 |
],
|
82 |
+
"reference_scores": [3, 3, 4]
|
83 |
},
|
84 |
{
|
85 |
+
"title": "Mechanical Persona",
|
86 |
+
"audio": "sample1_audio_path",
|
87 |
"sub_dims": [
|
88 |
+
"Flattery: Humans assess context to agree or disagree, sometimes offering differing opinions; machines excessively agree, thank, or apologize, over-validating the other party and lacking authentic interaction.",
|
89 |
+
"Formalized Expression: Human speech is flexible; machine responses are formally structured, overly written, and use vague wording."
|
90 |
],
|
91 |
"reference_scores": [5, 5]
|
92 |
},
|
93 |
{
|
94 |
+
"title": "Emotional Expression",
|
95 |
+
"audio": "sample1_audio_path",
|
96 |
"sub_dims": [
|
97 |
+
"Semantic Level: Humans show appropriate emotional responses to contexts like sadness or joy; machines are emotionally flat, or use emotional words vaguely and out of context.",
|
98 |
+
"Acoustic Level: Human pitch, volume, and rhythm change dynamically with emotion; machine emotional tone is formulaic or mismatched with the context."
|
99 |
],
|
100 |
+
"reference_scores": [3, 3]
|
101 |
}
|
102 |
]
|
103 |
|
104 |
DIMENSION_TITLES = [d["title"] for d in DIMENSIONS_DATA]
|
105 |
+
SPECIAL_KEYWORDS = ["Code-switching", "Metaphor and Pragmatic Intent", "Auxiliary Vocalizations", "Accent"]
|
106 |
MAX_SUB_DIMS = max(len(d['sub_dims']) for d in DIMENSIONS_DATA)
|
107 |
THE_SUB_DIMS = [d['sub_dims'] for d in DIMENSIONS_DATA]
|
108 |
|
|
|
371 |
sub_dims = dim_data["sub_dims"]
|
372 |
dim_title = dim_data["title"]
|
373 |
existing_scores = selections.get(dim_data['title'], {})
|
374 |
+
progress_d = f"Dimension {d_idx + 1} / {len(DIMENSIONS_DATA)}: **{dim_data['title']}**"
|
375 |
|
376 |
for i in range(MAX_SUB_DIMS):
|
377 |
if i < len(sub_dims):
|
378 |
desc = sub_dims[i]
|
379 |
# print(f"{desc} -> default value: {existing_scores.get(desc, 0)}")
|
380 |
+
name = desc.split(":")[0].strip()
|
381 |
default_value = 0 if name in SPECIAL_KEYWORDS else 1
|
382 |
value = existing_scores.get(desc, default_value)
|
383 |
|
|
|
400 |
# ))
|
401 |
else:
|
402 |
slider_updates.append(gr.update(visible=False))
|
403 |
+
# print(f"{desc} -> default value: {existing_scores.get(desc, 0)}")
|
404 |
# for i in range(MAX_SUB_DIMS):
|
405 |
# if i < len(dimension['sub_dims']):
|
406 |
# sub_dim_label = dimension['sub_dims'][i]
|
|
|
411 |
|
412 |
prev_btn_update = gr.update(interactive=(d_idx > 0))
|
413 |
next_btn_update = gr.update(
|
414 |
+
value="Proceed to Final Judgement" if d_idx == len(DIMENSIONS_DATA) - 1 else "Next Dimension",
|
415 |
interactive=True
|
416 |
)
|
417 |
|
|
|
420 |
def init_test_question(user_data, q_idx):
|
421 |
d_idx = 0
|
422 |
question = user_data["question_set"][q_idx]
|
423 |
+
progress_q = f"Question {q_idx + 1} / {len(user_data['question_set'])}"
|
424 |
|
425 |
initial_updates = update_test_dimension_view(d_idx, {})
|
426 |
dim_title_update, prev_btn_update, next_btn_update = initial_updates[:3]
|
|
|
664 |
return init_q_updates + (all_results, gr.update(value=""))
|
665 |
else:
|
666 |
# 准备完整结果数据
|
667 |
+
result_str = "### Test Completed!\n\nOverview of your submission:\n"
|
668 |
for res in all_results:
|
669 |
+
result_str += f"##### Final Judgement: **{res['selections'].get('final_choice', 'empty')}**\n" # empty == no choice
|
670 |
for dim_title, dim_data in res['selections'].items():
|
671 |
if dim_title == 'final_choice': continue
|
672 |
result_str += f"- **{dim_title}**:\n"
|
|
|
858 |
}
|
859 |
|
860 |
with welcome_page:
|
861 |
+
gr.Markdown("# AI Indentifier: Can you spot the AI?\n你将听到一系列对话,请判断哪个回应者是 AI。")
|
862 |
+
start_btn = gr.Button("Start", variant="primary")
|
863 |
|
864 |
with info_page:
|
865 |
gr.Markdown("## 请提供一些基本信息")
|