Spaces:
Sleeping
Sleeping
Apply color logic to multi-file and update sort system
Browse files
ui.py
CHANGED
|
@@ -402,8 +402,22 @@ def render_multifile_summary(plotly_config=None):
|
|
| 402 |
)
|
| 403 |
df7, _ = utils.build_multifile_voice_df(validNames, st.session_state.summaries)
|
| 404 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 405 |
fig6 = px.bar(df6, x="files", y=allCategories,
|
| 406 |
-
title="Percent of File Duration Spoken by Each Speaker/Role"
|
|
|
|
| 407 |
fig6.update_layout(yaxis_title="% of File Duration")
|
| 408 |
st.plotly_chart(fig6, use_container_width=True, config=cfg)
|
| 409 |
st.markdown(
|
|
@@ -415,20 +429,20 @@ def render_multifile_summary(plotly_config=None):
|
|
| 415 |
|
| 416 |
with st.container():
|
| 417 |
sort_options = {
|
| 418 |
-
"
|
| 419 |
-
"
|
| 420 |
-
"No Voice (most β least)": (["No Voice", "Multi Voice"], False),
|
| 421 |
}
|
| 422 |
selected_sort = st.selectbox(
|
| 423 |
"Sort cross-file voice categories by:",
|
| 424 |
options=list(sort_options.keys()),
|
| 425 |
key="multifile_voice_sort",
|
| 426 |
)
|
| 427 |
-
|
| 428 |
fig7 = px.bar(
|
| 429 |
-
df7.sort_values(by=
|
| 430 |
x="files", y=["Single Voice", "Multi Voice", "No Voice"],
|
| 431 |
title=f"Cross-file Voice Categories sorted by {selected_sort}",
|
|
|
|
| 432 |
)
|
| 433 |
fig7.update_layout(yaxis_title="% of File Duration")
|
| 434 |
st.plotly_chart(fig7, use_container_width=True, config=cfg)
|
|
@@ -441,23 +455,30 @@ def render_multifile_summary(plotly_config=None):
|
|
| 441 |
st.session_state.categories, st.session_state.categorySelect,
|
| 442 |
speakerRenames=st.session_state.speakerRenames,
|
| 443 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
with st.container():
|
| 445 |
-
role_sort_options = {
|
| 446 |
-
|
| 447 |
-
|
| 448 |
-
|
| 449 |
-
else:
|
| 450 |
-
role_sort_options[f"{col} (least β most)"] = ([col], True)
|
| 451 |
|
| 452 |
selected_role_sort = st.selectbox(
|
| 453 |
"Sort cross-file role/voice breakdown by:",
|
| 454 |
options=list(role_sort_options.keys()),
|
| 455 |
key="multifile_role_voice_sort",
|
| 456 |
)
|
| 457 |
-
|
| 458 |
fig8 = px.bar(
|
| 459 |
-
df8.sort_values(by=
|
| 460 |
x="files", y=role_voice_cols,
|
|
|
|
| 461 |
title=f"Cross-file Role & Voice Breakdown sorted by {selected_role_sort}",
|
| 462 |
)
|
| 463 |
fig8.update_layout(yaxis_title="% of File Duration")
|
|
|
|
| 402 |
)
|
| 403 |
df7, _ = utils.build_multifile_voice_df(validNames, st.session_state.summaries)
|
| 404 |
|
| 405 |
+
# Build consistent color maps using the same _PALETTE as per-file charts
|
| 406 |
+
# Voice category colors β always fixed
|
| 407 |
+
voice_color_map = {
|
| 408 |
+
"Single Voice": utils._PALETTE[0], # red shade 0
|
| 409 |
+
"Multi Voice": utils._PALETTE[9], # green shade 0
|
| 410 |
+
"No Voice": utils._PALETTE[-1], # grey
|
| 411 |
+
}
|
| 412 |
+
# Role/speaker colors β cycle through _SPEAKER_PALETTE by position
|
| 413 |
+
role_color_map = {
|
| 414 |
+
col: utils._SPEAKER_PALETTE[i % len(utils._SPEAKER_PALETTE)]
|
| 415 |
+
for i, col in enumerate(allCategories)
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
fig6 = px.bar(df6, x="files", y=allCategories,
|
| 419 |
+
title="Percent of File Duration Spoken by Each Speaker/Role",
|
| 420 |
+
color_discrete_map=role_color_map)
|
| 421 |
fig6.update_layout(yaxis_title="% of File Duration")
|
| 422 |
st.plotly_chart(fig6, use_container_width=True, config=cfg)
|
| 423 |
st.markdown(
|
|
|
|
| 429 |
|
| 430 |
with st.container():
|
| 431 |
sort_options = {
|
| 432 |
+
"File Name": ("files", True),
|
| 433 |
+
"% of Single Voice": ("Single Voice", False),
|
|
|
|
| 434 |
}
|
| 435 |
selected_sort = st.selectbox(
|
| 436 |
"Sort cross-file voice categories by:",
|
| 437 |
options=list(sort_options.keys()),
|
| 438 |
key="multifile_voice_sort",
|
| 439 |
)
|
| 440 |
+
sort_col, ascending = sort_options[selected_sort]
|
| 441 |
fig7 = px.bar(
|
| 442 |
+
df7.sort_values(by=sort_col, ascending=ascending),
|
| 443 |
x="files", y=["Single Voice", "Multi Voice", "No Voice"],
|
| 444 |
title=f"Cross-file Voice Categories sorted by {selected_sort}",
|
| 445 |
+
color_discrete_map=voice_color_map,
|
| 446 |
)
|
| 447 |
fig7.update_layout(yaxis_title="% of File Duration")
|
| 448 |
st.plotly_chart(fig7, use_container_width=True, config=cfg)
|
|
|
|
| 455 |
st.session_state.categories, st.session_state.categorySelect,
|
| 456 |
speakerRenames=st.session_state.speakerRenames,
|
| 457 |
)
|
| 458 |
+
# Combined map: roles use role colors, voice categories use fixed colors
|
| 459 |
+
role_voice_color_map = {
|
| 460 |
+
col: utils._SPEAKER_PALETTE[i % len(utils._SPEAKER_PALETTE)]
|
| 461 |
+
for i, col in enumerate(role_voice_cols)
|
| 462 |
+
if col not in voice_color_map
|
| 463 |
+
}
|
| 464 |
+
role_voice_color_map.update(voice_color_map)
|
| 465 |
+
|
| 466 |
with st.container():
|
| 467 |
+
role_sort_options = {
|
| 468 |
+
"File Name": ("files", True),
|
| 469 |
+
"% of Single Voice": ("Single Voice", False),
|
| 470 |
+
}
|
|
|
|
|
|
|
| 471 |
|
| 472 |
selected_role_sort = st.selectbox(
|
| 473 |
"Sort cross-file role/voice breakdown by:",
|
| 474 |
options=list(role_sort_options.keys()),
|
| 475 |
key="multifile_role_voice_sort",
|
| 476 |
)
|
| 477 |
+
sort_col8, ascending8 = role_sort_options[selected_role_sort]
|
| 478 |
fig8 = px.bar(
|
| 479 |
+
df8.sort_values(by=sort_col8, ascending=ascending8),
|
| 480 |
x="files", y=role_voice_cols,
|
| 481 |
+
color_discrete_map=role_voice_color_map,
|
| 482 |
title=f"Cross-file Role & Voice Breakdown sorted by {selected_role_sort}",
|
| 483 |
)
|
| 484 |
fig8.update_layout(yaxis_title="% of File Duration")
|