Spark Chou commited on
Commit
76578a8
·
1 Parent(s): 5d0ff5c
Files changed (1) hide show
  1. app.py +42 -42
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, 5, 0, 5, 5, 0]
62
  },
63
  {
64
- "title": "非生理性副语言特征",
65
- "audio": sample1_audio_path,
66
  "sub_dims": [
67
- "节奏:偏人类:语速随语义起伏,偶尔卡顿或犹豫;偏机器:说话几乎无停顿或停顿机械",
68
- "语调:偏人类:在表达如疑问、惊讶、强调时,音调会自然上扬或下降;偏机器:语调单一或变化过于规律,不符合语境",
69
- "重读:偏人类:有意识地重读重要词语,突出重点;偏机器:没有重读词语或或出现强调部位异常",
70
- "辅助性发声:偏人类:发出符合语境的非语言声音,如笑声、叹气等;偏机器:辅助性发声语境错误或机械化,或完全无辅助性发声"
71
  ],
72
- "reference_scores": [5, 5, 5, 5]
73
  },
74
  {
75
- "title": "生理性副语言特征",
76
- "audio": sample1_audio_path,
77
  "sub_dims": [
78
- "微生理杂音:偏人类:说话存在呼吸声、口水音、气泡音等无意识发声,且自然地出现在说话中;偏机器:语音过于干净,或发出不自然杂音(电流声)",
79
- "发音不稳定性:偏人类:发音存在一定不规则性(诸如连读、颤音、含糊发音、鼻音等);偏机器:发音过于清晰规则",
80
- "口音:偏人类:存在自然的地区口音或语音特征;偏机器:口音生硬"
81
  ],
82
- "reference_scores": [5, 4, 4]
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": [5, 5]
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"维度 {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,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="进入最终判断" if d_idx == len(DIMENSIONS_DATA) - 1 else "下一维度",
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" {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,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 = "### 测试全部完成!\n\n你的提交结果概览:\n"
668
  for res in all_results:
669
- result_str += f"##### 最终判断: **{res['selections'].get('final_choice', '未选择')}**\n"
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 识破者\n你将听到一系列对话,请判断哪个回应者是 AI。")
862
- start_btn = gr.Button("开始挑战", variant="primary")
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("## 请提供一些基本信息")