Spaces:
Starting on CPU Upgrade
Starting on CPU Upgrade
Make changes to multi-file graphs
Browse files
ui.py
CHANGED
|
@@ -193,32 +193,6 @@ def render_rename_sidebar(currFile, speakerNames, display_speaker_tokens, token_
|
|
| 193 |
)
|
| 194 |
|
| 195 |
|
| 196 |
-
# ---------------------------------------------------------------------------
|
| 197 |
-
# Data tab β custom scrollable table
|
| 198 |
-
# ---------------------------------------------------------------------------
|
| 199 |
-
|
| 200 |
-
def render_data_table(tableDF, speakerNames, raw_to_display, currFile):
|
| 201 |
-
"""Render the custom column-based scrollable table (Speaker, Start, Finish)."""
|
| 202 |
-
other_cols = [c for c in tableDF.columns if c != "Speaker"]
|
| 203 |
-
col_widths = [2] + [1] * len(other_cols)
|
| 204 |
-
|
| 205 |
-
# Header
|
| 206 |
-
header_cols = st.columns(col_widths)
|
| 207 |
-
header_cols[0].markdown("**Speaker**")
|
| 208 |
-
for i, col_name in enumerate(other_cols):
|
| 209 |
-
header_cols[i + 1].markdown(f"**{col_name}**")
|
| 210 |
-
|
| 211 |
-
st.markdown("<hr style='margin-top:2px; margin-bottom:4px;'>", unsafe_allow_html=True)
|
| 212 |
-
|
| 213 |
-
with st.container(height=480, border=False):
|
| 214 |
-
for _, row in tableDF.iterrows():
|
| 215 |
-
row_cols = st.columns(col_widths)
|
| 216 |
-
display_sp = row["Speaker"]
|
| 217 |
-
row_cols[0].write(display_sp)
|
| 218 |
-
for i, col_name in enumerate(other_cols):
|
| 219 |
-
row_cols[i + 1].write(row[col_name])
|
| 220 |
-
|
| 221 |
-
|
| 222 |
# ---------------------------------------------------------------------------
|
| 223 |
# Rename Speaker tab β speaker / audio sample table
|
| 224 |
# ---------------------------------------------------------------------------
|
|
@@ -426,20 +400,35 @@ def render_multifile_summary(plotly_config=None):
|
|
| 426 |
st.session_state.categories, st.session_state.categorySelect,
|
| 427 |
speakerRenames=st.session_state.speakerRenames,
|
| 428 |
)
|
| 429 |
-
|
| 430 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 431 |
fig6.update_layout(yaxis_title="Proportion of File Duration")
|
| 432 |
st.plotly_chart(fig6, use_container_width=True, config=cfg)
|
| 433 |
-
st.caption("Note: Overlaps between speakers of the same role are only counted once.")
|
| 434 |
-
|
| 435 |
-
|
| 436 |
-
|
| 437 |
-
|
| 438 |
-
(["
|
| 439 |
-
|
| 440 |
-
|
| 441 |
-
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
)
|
| 194 |
|
| 195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
# ---------------------------------------------------------------------------
|
| 197 |
# Rename Speaker tab β speaker / audio sample table
|
| 198 |
# ---------------------------------------------------------------------------
|
|
|
|
| 400 |
st.session_state.categories, st.session_state.categorySelect,
|
| 401 |
speakerRenames=st.session_state.speakerRenames,
|
| 402 |
)
|
| 403 |
+
df7, _ = utils.build_multifile_voice_df(validNames, st.session_state.summaries)
|
| 404 |
+
|
| 405 |
+
# Add No Voice (silence) to the speaker/role chart.
|
| 406 |
+
# df7 percentiles are 0-100, df6 uses 0-1 proportions.
|
| 407 |
+
no_voice_map = dict(zip(df7["files"], df7["No Voice"] / 100))
|
| 408 |
+
df6["No Voice"] = df6["files"].map(no_voice_map).fillna(0)
|
| 409 |
+
chart_cols = allCategories + ["No Voice"]
|
| 410 |
+
|
| 411 |
+
fig6 = px.bar(df6, x="files", y=chart_cols,
|
| 412 |
+
title="Proportion of File Duration Spoken by Each Speaker/Role *")
|
| 413 |
fig6.update_layout(yaxis_title="Proportion of File Duration")
|
| 414 |
st.plotly_chart(fig6, use_container_width=True, config=cfg)
|
| 415 |
+
st.caption("* Note: Overlaps between speakers of the same role are only counted once.")
|
| 416 |
+
|
| 417 |
+
sort_options = {
|
| 418 |
+
"Single Voice (least β most)": (["Single Voice", "Multi Voice"], True),
|
| 419 |
+
"Multi Voice (least β most)": (["Multi Voice", "Single Voice"], True),
|
| 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 |
+
sort_cols, ascending = sort_options[selected_sort]
|
| 428 |
+
fig7 = px.bar(
|
| 429 |
+
df7.sort_values(by=sort_cols, ascending=ascending),
|
| 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="Proportion of File Duration")
|
| 434 |
+
st.plotly_chart(fig7, use_container_width=True, config=cfg)
|