Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -38,77 +38,49 @@ DIMENSIONS_DATA = [
|
|
| 38 |
{
|
| 39 |
"title": "语义和语用特征",
|
| 40 |
"audio": sample1_audio_path,
|
| 41 |
-
"desc": "这是“语义和语用特征”维度的文本描述示例。",
|
| 42 |
"sub_dims": [
|
| 43 |
"记忆一致性:回应者是否能够正确并正确并延续并记忆并延续对话信息?是否存在对上下文的误解或不自洽?", "逻辑连贯性:回应者在语义与对话结构上保持前后一致、合乎逻辑?是否存在前后矛盾的情况?",
|
| 44 |
"常见多音字处理:是否能再上下文中正确使用常见多音字?", "多语言混杂:是否存在自然的语言切换现象?如中英混杂、文化化表达。",
|
| 45 |
"语言不精确性:是否出现打断、自纠正等人类似语言行为?是否存在如“差不多”、“可能吧”这类表达不确定性的用法?", "填充词使用:如“呃”、“嗯”等自然语流中的停顿或过渡词,使用是否得体且自然?",
|
| 46 |
"隐喻与语用用意:是否展现出复杂的语用功能(如讽刺、劝阻、暗示等),以及对活在含义层次的理解能力?"
|
| 47 |
],
|
| 48 |
-
"
|
| 49 |
-
<p>🔴 <strong>记忆一致性:</strong> 在说话人明确提出自己已经中年后,回应者仍做出了他是青少年的错误假定</p>
|
| 50 |
-
<p>🔴 <strong>逻辑连贯性:</strong> 回应者在第一轮对话中说他说的话并不重要,但在第二轮对话中说他说的话“能够改变你的一生”</p>
|
| 51 |
-
<p>🔴 <strong>常见多音字处理:</strong> 该条对话中未出现多音字</p>
|
| 52 |
-
<p>🟢 <strong>多语言混杂:</strong> 回应者在回复中夹杂了"I see",回复中存在多语言混杂</p>
|
| 53 |
-
<p>🔴 <strong>语言不精确性:</strong> 回应者使用的语言中未夹杂任何的不确定性</p>
|
| 54 |
-
<p>🟢 <strong>填充词使用:</strong> 回应者在回复中使用了“嗯”这个填充词</p>
|
| 55 |
-
<p>🔴 <strong>隐喻与语用用意:</strong> 回应者误将说话人的挖苦当成了真心的赞扬</p>
|
| 56 |
-
"""
|
| 57 |
},
|
| 58 |
{
|
| 59 |
"title": "非生理性副语言特征",
|
| 60 |
"audio": sample1_audio_path,
|
| 61 |
-
"desc": "这是“非生理性副语言特征”维度的文本描述示例。",
|
| 62 |
"sub_dims": [
|
| 63 |
"节奏:回应者是否存在自然的停顿?语速是否存在自然、流畅的变化?", "语调:在表达疑问、惊讶、强调时,回应者的音调是否会自然上扬或下降?是否表现出符合语境的变化?",
|
| 64 |
"重读:是否存在句中关键词上有意识地加重语气?", "辅助性发声:是否存在叹气、短哼、笑声等辅助情绪的非语言性发声?这些发声是否在语境中正确表达了情绪或意图?"
|
| 65 |
],
|
| 66 |
-
"
|
| 67 |
-
<p>🟢 <strong>节奏:</strong> 回应者的语速变化、停顿都较为自然</p>
|
| 68 |
-
<p>🔴 <strong>语调:</strong> 回应者的音调不存在显著变化</p>
|
| 69 |
-
<p>🔴 <strong>重读:</strong> 回应者语气不存在显著变化</p>
|
| 70 |
-
<p>🔴 <strong>辅助性发声:</strong> 尽管回应者发出了叹气的声音,但是该发声并未传递出语境下应有的失落情堵</p>
|
| 71 |
-
"""
|
| 72 |
},
|
| 73 |
{
|
| 74 |
"title": "生理性副语言特征",
|
| 75 |
"audio": sample1_audio_path,
|
| 76 |
-
"desc": "这是“生理性副语言特征”维度的文本描述示例。",
|
| 77 |
"sub_dims": [
|
| 78 |
"微生理杂音:回应中是否出现如呼吸声、口水音、气泡音等无意识发声?这些发声是否自然地穿插在恰当的语流节奏当中?",
|
| 79 |
"发音不稳定性:回应者是否出现连读、颤音、鼻音等不稳定发音?", "口音:(如果存在的话)回应者的口音是否自然?是否存在机械式的元辅音发音风格?"
|
| 80 |
],
|
| 81 |
-
"
|
| 82 |
-
<p>🔴 <strong>微生理杂音:</strong> 回应中不存在任何无意识发声</p>
|
| 83 |
-
<p>🔴 <strong>发音不稳定性:</strong> 回应者的咬字清晰、发音标准</p>
|
| 84 |
-
<p>🟢 <strong>口音:</strong> 回应者的口音自然</p>
|
| 85 |
-
"""
|
| 86 |
},
|
| 87 |
{
|
| 88 |
"title": "机械人格",
|
| 89 |
"audio": sample1_audio_path,
|
| 90 |
-
"desc": "这是“机械人格”维度的文本描述示例。",
|
| 91 |
"sub_dims": [
|
| 92 |
"谄媚现象:回应者是否频繁地赞同用户、重复用户的说法、不断表示感谢或道歉?是否存在“无论用户说什么都肯定或支持”的语气模式?",
|
| 93 |
"书面化表达:回应的内容是否缺乏口���化特征?句式是否整齐划一、结构完整却缺乏真实交流中的松散感或灵活性?是否使用抽象或泛泛的措辞来回避具体问题?"
|
| 94 |
],
|
| 95 |
-
"
|
| 96 |
-
<p>🟢 <strong>谄媚现象:</strong> 回应者并未明显表现出谄媚现象的特征</p>
|
| 97 |
-
<p>🔴 <strong>书面化表达:</strong> 回应的内容结构过于缜密,符合书面用语特征</p>
|
| 98 |
-
"""
|
| 99 |
},
|
| 100 |
{
|
| 101 |
"title": "情感表达",
|
| 102 |
"audio": sample1_audio_path,
|
| 103 |
-
"desc": "这是“情感表达”维度的文本描述示例。",
|
| 104 |
"sub_dims": [
|
| 105 |
"语义层面:回应者的语言内容是否体现出符合上下文的情绪反应?是否表达了人类对某些情境应有的情感态度?",
|
| 106 |
"声学层面:回应者的声音情绪是否与语义一致?语调是否有自然的高低起伏来表达情绪变化?是否出现回应内容与声音传达出的情绪不吻合的现象?"
|
| 107 |
],
|
| 108 |
-
"
|
| 109 |
-
<p>🔴 <strong>语义层面:</strong> 说话者阐述了一件伤心的事情,而回应者的语言内容中体现出了恰当的悲伤情绪</p>
|
| 110 |
-
<p>🟢 <strong>声学层面:</strong> 回应者的语音特征与情感表达不匹配。语言内容中表达出了悲伤的情感,但语音特征平淡、缺少变化</p>
|
| 111 |
-
"""
|
| 112 |
}
|
| 113 |
]
|
| 114 |
|
|
@@ -202,16 +174,27 @@ def show_sample_page_and_init(age, gender, education, education_other, user_data
|
|
| 202 |
def update_sample_view(dimension_title):
|
| 203 |
dim_data = next((d for d in DIMENSIONS_DATA if d["title"] == dimension_title), None)
|
| 204 |
if dim_data:
|
| 205 |
-
|
| 206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
for i in range(MAX_SUB_DIMS):
|
| 208 |
if i < len(dim_data['sub_dims']):
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
| 210 |
else:
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
|
| 216 |
def update_test_dimension_view(d_idx, selections):
|
| 217 |
dimension = DIMENSIONS_DATA[d_idx]
|
|
@@ -465,16 +448,21 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
|
|
| 465 |
education_other_input = gr.Textbox(label="请填写你的学历", visible=False, interactive=False)
|
| 466 |
submit_info_btn = gr.Button("提交并开始学习样例", variant="primary", interactive=False)
|
| 467 |
|
| 468 |
-
|
| 469 |
-
gr.Markdown("## 样例分析\n请选择一个维度进行学习和打分练习。所有维度共用同一个样例音频。")
|
| 470 |
sample_dimension_selector = gr.Radio(DIMENSION_TITLES, label="选择学习维度", value=DIMENSION_TITLES[0])
|
| 471 |
with gr.Row():
|
| 472 |
with gr.Column(scale=1):
|
| 473 |
sample_audio = gr.Audio(label="样例音频", value=DIMENSIONS_DATA[0]["audio"])
|
| 474 |
with gr.Column(scale=2):
|
| 475 |
-
gr.
|
| 476 |
-
|
| 477 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 478 |
|
| 479 |
with pretest_page:
|
| 480 |
gr.Markdown("## 测试说明\n"
|
|
@@ -509,7 +497,10 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
|
|
| 509 |
# ==============================================================================
|
| 510 |
# 事件绑定 (Event Binding) & IO 列表定义
|
| 511 |
# ==============================================================================
|
| 512 |
-
sample_init_outputs = [
|
|
|
|
|
|
|
|
|
|
| 513 |
|
| 514 |
test_init_outputs = [
|
| 515 |
pretest_page, test_page, final_judgment_page, result_page,
|
|
@@ -546,7 +537,13 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
|
|
| 546 |
sample_dimension_selector.change(
|
| 547 |
fn=update_sample_view,
|
| 548 |
inputs=sample_dimension_selector,
|
| 549 |
-
outputs=[sample_audio] + sample_sliders
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 550 |
)
|
| 551 |
|
| 552 |
go_to_pretest_btn.click(lambda: (gr.update(visible=False), gr.update(visible=True)), outputs=[sample_page, pretest_page])
|
|
|
|
| 38 |
{
|
| 39 |
"title": "语义和语用特征",
|
| 40 |
"audio": sample1_audio_path,
|
|
|
|
| 41 |
"sub_dims": [
|
| 42 |
"记忆一致性:回应者是否能够正确并正确并延续并记忆并延续对话信息?是否存在对上下文的误解或不自洽?", "逻辑连贯性:回应者在语义与对话结构上保持前后一致、合乎逻辑?是否存在前后矛盾的情况?",
|
| 43 |
"常见多音字处理:是否能再上下文中正确使用常见多音字?", "多语言混杂:是否存在自然的语言切换现象?如中英混杂、文化化表达。",
|
| 44 |
"语言不精确性:是否出现打断、自纠正等人类似语言行为?是否存在如“差不多”、“可能吧”这类表达不确定性的用法?", "填充词使用:如“呃”、“嗯”等自然语流中的停顿或过渡词,使用是否得体且自然?",
|
| 45 |
"隐喻与语用用意:是否展现出复杂的语用功能(如讽刺、劝阻、暗示等),以及对活在含义层次的理解能力?"
|
| 46 |
],
|
| 47 |
+
"reference_scores": [1, 1, 1, 5, 1, 5, 1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
},
|
| 49 |
{
|
| 50 |
"title": "非生理性副语言特征",
|
| 51 |
"audio": sample1_audio_path,
|
|
|
|
| 52 |
"sub_dims": [
|
| 53 |
"节奏:回应者是否存在自然的停顿?语速是否存在自然、流畅的变化?", "语调:在表达疑问、惊讶、强调时,回应者的音调是否会自然上扬或下降?是否表现出符合语境的变化?",
|
| 54 |
"重读:是否存在句中关键词上有意识地加重语气?", "辅助性发声:是否存在叹气、短哼、笑声等辅助情绪的非语言性发声?这些发声是否在语境中正确表达了情绪或意图?"
|
| 55 |
],
|
| 56 |
+
"reference_scores": [5, 1, 5, 1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
},
|
| 58 |
{
|
| 59 |
"title": "生理性副语言特征",
|
| 60 |
"audio": sample1_audio_path,
|
|
|
|
| 61 |
"sub_dims": [
|
| 62 |
"微生理杂音:回应中是否出现如呼吸声、口水音、气泡音等无意识发声?这些发声是否自然地穿插在恰当的语流节奏当中?",
|
| 63 |
"发音不稳定性:回应者是否出现连读、颤音、鼻音等不稳定发音?", "口音:(如果存在的话)回应者的口音是否自然?是否存在机械式的元辅音发音风格?"
|
| 64 |
],
|
| 65 |
+
"reference_scores": [1, 1, 5]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
},
|
| 67 |
{
|
| 68 |
"title": "机械人格",
|
| 69 |
"audio": sample1_audio_path,
|
|
|
|
| 70 |
"sub_dims": [
|
| 71 |
"谄媚现象:回应者是否频繁地赞同用户、重复用户的说法、不断表示感谢或道歉?是否存在“无论用户说什么都肯定或支持”的语气模式?",
|
| 72 |
"书面化表达:回应的内容是否缺乏口���化特征?句式是否整齐划一、结构完整却缺乏真实交流中的松散感或灵活性?是否使用抽象或泛泛的措辞来回避具体问题?"
|
| 73 |
],
|
| 74 |
+
"reference_scores": [1, 5]
|
|
|
|
|
|
|
|
|
|
| 75 |
},
|
| 76 |
{
|
| 77 |
"title": "情感表达",
|
| 78 |
"audio": sample1_audio_path,
|
|
|
|
| 79 |
"sub_dims": [
|
| 80 |
"语义层面:回应者的语言内容是否体现出符合上下文的情绪反应?是否表达了人类对某些情境应有的情感态度?",
|
| 81 |
"声学层面:回应者的声音情绪是否与语义一致?语调是否有自然的高低起伏来表达情绪变化?是否出现回应内容与声音传达出的情绪不吻合的现象?"
|
| 82 |
],
|
| 83 |
+
"reference_scores": [5, 1]
|
|
|
|
|
|
|
|
|
|
| 84 |
}
|
| 85 |
]
|
| 86 |
|
|
|
|
| 174 |
def update_sample_view(dimension_title):
|
| 175 |
dim_data = next((d for d in DIMENSIONS_DATA if d["title"] == dimension_title), None)
|
| 176 |
if dim_data:
|
| 177 |
+
audio_up = gr.update(value=dim_data["audio"])
|
| 178 |
+
interactive_view_up = gr.update(visible=True)
|
| 179 |
+
reference_view_up = gr.update(visible=False)
|
| 180 |
+
reference_btn_up = gr.update(value="参考")
|
| 181 |
+
sample_slider_ups = []
|
| 182 |
+
ref_slider_ups = []
|
| 183 |
+
scores = dim_data.get("reference_scores", [])
|
| 184 |
+
|
| 185 |
for i in range(MAX_SUB_DIMS):
|
| 186 |
if i < len(dim_data['sub_dims']):
|
| 187 |
+
label = dim_data['sub_dims'][i]
|
| 188 |
+
score = scores[i] if i < len(scores) else 0
|
| 189 |
+
sample_slider_ups.append(gr.update(visible=True, label=label, value=0))
|
| 190 |
+
ref_slider_ups.append(gr.update(visible=True, label=label, value=score))
|
| 191 |
else:
|
| 192 |
+
sample_slider_ups.append(gr.update(visible=False, value=0))
|
| 193 |
+
ref_slider_ups.append(gr.update(visible=False, value=0))
|
| 194 |
+
return [audio_up, interactive_view_up, reference_view_up, reference_btn_up] + sample_slider_ups + ref_slider_ups
|
| 195 |
+
empty_updates = [gr.update()] * 4
|
| 196 |
+
slider_empty_updates = [gr.update()] * (MAX_SUB_DIMS * 2)
|
| 197 |
+
return empty_updates + slider_empty_updates
|
| 198 |
|
| 199 |
def update_test_dimension_view(d_idx, selections):
|
| 200 |
dimension = DIMENSIONS_DATA[d_idx]
|
|
|
|
| 448 |
education_other_input = gr.Textbox(label="请填写你的学历", visible=False, interactive=False)
|
| 449 |
submit_info_btn = gr.Button("提交并开始学习样例", variant="primary", interactive=False)
|
| 450 |
|
| 451 |
+
gr.Markdown("## 样例分析\n请选择一个维度进行学习和打分练习。所有维度共用同一个样例音频。")
|
|
|
|
| 452 |
sample_dimension_selector = gr.Radio(DIMENSION_TITLES, label="选择学习维度", value=DIMENSION_TITLES[0])
|
| 453 |
with gr.Row():
|
| 454 |
with gr.Column(scale=1):
|
| 455 |
sample_audio = gr.Audio(label="样例音频", value=DIMENSIONS_DATA[0]["audio"])
|
| 456 |
with gr.Column(scale=2):
|
| 457 |
+
with gr.Column(visible=True) as interactive_view:
|
| 458 |
+
gr.Markdown("#### 请为以下特征打分 (0-5分。0对应机器,5对应人类)")
|
| 459 |
+
sample_sliders = [gr.Slider(minimum=0, maximum=5, step=1, label=f"Sub-dim {i+1}", visible=False, interactive=True) for i in range(MAX_SUB_DIMS)]
|
| 460 |
+
with gr.Column(visible=False) as reference_view:
|
| 461 |
+
gr.Markdown("### 参考答案解析 (0-5分。0对应机器,5对应人类)")
|
| 462 |
+
reference_sliders = [gr.Slider(minimum=0, maximum=5, step=1, label=f"Sub-dim {i+1}", visible=False, interactive=False) for i in range(MAX_SUB_DIMS)]
|
| 463 |
+
with gr.Row():
|
| 464 |
+
reference_btn = gr.Button("参考")
|
| 465 |
+
go_to_pretest_btn = gr.Button("我明白了,开始测试", variant="primary")
|
| 466 |
|
| 467 |
with pretest_page:
|
| 468 |
gr.Markdown("## 测试说明\n"
|
|
|
|
| 497 |
# ==============================================================================
|
| 498 |
# 事件绑定 (Event Binding) & IO 列表定义
|
| 499 |
# ==============================================================================
|
| 500 |
+
sample_init_outputs = [
|
| 501 |
+
info_page, sample_page, user_data_state, sample_dimension_selector,
|
| 502 |
+
sample_audio, interactive_view, reference_view, reference_btn
|
| 503 |
+
] + sample_sliders + reference_sliders
|
| 504 |
|
| 505 |
test_init_outputs = [
|
| 506 |
pretest_page, test_page, final_judgment_page, result_page,
|
|
|
|
| 537 |
sample_dimension_selector.change(
|
| 538 |
fn=update_sample_view,
|
| 539 |
inputs=sample_dimension_selector,
|
| 540 |
+
outputs=[sample_audio, interactive_view, reference_view, reference_btn] + sample_sliders + reference_sliders
|
| 541 |
+
)
|
| 542 |
+
|
| 543 |
+
reference_btn.click(
|
| 544 |
+
fn=toggle_reference_view,
|
| 545 |
+
inputs=reference_btn,
|
| 546 |
+
outputs=[interactive_view, reference_view, reference_btn]
|
| 547 |
)
|
| 548 |
|
| 549 |
go_to_pretest_btn.click(lambda: (gr.update(visible=False), gr.update(visible=True)), outputs=[sample_page, pretest_page])
|