Spaces:
Sleeping
Sleeping
Add new tab Rename Speaker
Browse files
ui.py
CHANGED
|
@@ -119,52 +119,64 @@ def render_rename_sidebar(currFile, speakerNames, all_speaker_tokens):
|
|
| 119 |
# ---------------------------------------------------------------------------
|
| 120 |
|
| 121 |
def render_data_table(tableDF, speakerNames, raw_to_display, currFile):
|
| 122 |
-
"""Render the custom column-based table
|
| 123 |
-
file_clips = st.session_state.speakerClips.get(currFile, {})
|
| 124 |
-
has_clips = bool(file_clips)
|
| 125 |
-
has_waveform = currFile in st.session_state.speakerWaveforms
|
| 126 |
-
has_extras = has_clips
|
| 127 |
-
|
| 128 |
other_cols = [c for c in tableDF.columns if c != "Speaker"]
|
| 129 |
-
col_widths = [2] + [1] * len(other_cols)
|
| 130 |
|
| 131 |
# Header
|
| 132 |
header_cols = st.columns(col_widths)
|
| 133 |
header_cols[0].markdown("**Speaker**")
|
| 134 |
for i, col_name in enumerate(other_cols):
|
| 135 |
header_cols[i + 1].markdown(f"**{col_name}**")
|
| 136 |
-
if has_extras:
|
| 137 |
-
header_cols[-2].markdown("**Clip**")
|
| 138 |
-
header_cols[-1].markdown("** **", unsafe_allow_html=True)
|
| 139 |
|
| 140 |
st.markdown("<hr style='margin-top:2px; margin-bottom:4px;'>", unsafe_allow_html=True)
|
| 141 |
|
| 142 |
-
rendered_clip_for: set = set()
|
| 143 |
-
|
| 144 |
with st.container(height=480, border=False):
|
| 145 |
for _, row in tableDF.iterrows():
|
| 146 |
row_cols = st.columns(col_widths)
|
| 147 |
display_sp = row["Speaker"]
|
| 148 |
-
raw_key = next(
|
| 149 |
-
(sp for sp in speakerNames if raw_to_display.get(sp, sp) == display_sp),
|
| 150 |
-
display_sp,
|
| 151 |
-
)
|
| 152 |
-
|
| 153 |
row_cols[0].write(display_sp)
|
| 154 |
for i, col_name in enumerate(other_cols):
|
| 155 |
row_cols[i + 1].write(row[col_name])
|
| 156 |
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
|
| 170 |
# ---------------------------------------------------------------------------
|
|
@@ -209,4 +221,4 @@ def render_multifile_summary(plotly_config=None):
|
|
| 209 |
x="files", y=["One Voice", "Multi Voice", "No Voice"],
|
| 210 |
title=title),
|
| 211 |
use_container_width=True, config=cfg,
|
| 212 |
-
)
|
|
|
|
| 119 |
# ---------------------------------------------------------------------------
|
| 120 |
|
| 121 |
def render_data_table(tableDF, speakerNames, raw_to_display, currFile):
|
| 122 |
+
"""Render the custom column-based scrollable table (Speaker, Start, Finish)."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
other_cols = [c for c in tableDF.columns if c != "Speaker"]
|
| 124 |
+
col_widths = [2] + [1] * len(other_cols)
|
| 125 |
|
| 126 |
# Header
|
| 127 |
header_cols = st.columns(col_widths)
|
| 128 |
header_cols[0].markdown("**Speaker**")
|
| 129 |
for i, col_name in enumerate(other_cols):
|
| 130 |
header_cols[i + 1].markdown(f"**{col_name}**")
|
|
|
|
|
|
|
|
|
|
| 131 |
|
| 132 |
st.markdown("<hr style='margin-top:2px; margin-bottom:4px;'>", unsafe_allow_html=True)
|
| 133 |
|
|
|
|
|
|
|
| 134 |
with st.container(height=480, border=False):
|
| 135 |
for _, row in tableDF.iterrows():
|
| 136 |
row_cols = st.columns(col_widths)
|
| 137 |
display_sp = row["Speaker"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
row_cols[0].write(display_sp)
|
| 139 |
for i, col_name in enumerate(other_cols):
|
| 140 |
row_cols[i + 1].write(row[col_name])
|
| 141 |
|
| 142 |
+
|
| 143 |
+
# ---------------------------------------------------------------------------
|
| 144 |
+
# Rename Speaker tab — speaker / audio sample table
|
| 145 |
+
# ---------------------------------------------------------------------------
|
| 146 |
+
|
| 147 |
+
def render_speaker_samples_tab(speakerNames, raw_to_display, currFile):
|
| 148 |
+
"""Render a two-column table: Speaker name | Audio sample + randomize button."""
|
| 149 |
+
file_samples = st.session_state.speakerClips.get(currFile, {})
|
| 150 |
+
has_waveform = currFile in st.session_state.speakerWaveforms
|
| 151 |
+
has_samples = bool(file_samples)
|
| 152 |
+
|
| 153 |
+
# Header
|
| 154 |
+
header_cols = st.columns([2, 3, 1])
|
| 155 |
+
header_cols[0].markdown("**Speaker**")
|
| 156 |
+
header_cols[1].markdown("**Audio Sample**")
|
| 157 |
+
header_cols[2].markdown("** **", unsafe_allow_html=True)
|
| 158 |
+
st.markdown("<hr style='margin-top:2px; margin-bottom:4px;'>", unsafe_allow_html=True)
|
| 159 |
+
|
| 160 |
+
if not has_samples:
|
| 161 |
+
st.info("Audio samples are only available for files analyzed from audio (not RTTM/CSV/TXT).")
|
| 162 |
+
return
|
| 163 |
+
|
| 164 |
+
for sp in speakerNames:
|
| 165 |
+
display_name = raw_to_display.get(sp, sp)
|
| 166 |
+
row_cols = st.columns([2, 3, 1])
|
| 167 |
+
row_cols[0].write(display_name)
|
| 168 |
+
if sp in file_samples:
|
| 169 |
+
row_cols[1].audio(file_samples[sp], format="audio/wav")
|
| 170 |
+
sp_segs = st.session_state.speakerSegments.get(currFile, {}).get(sp, [])
|
| 171 |
+
if has_waveform and sp_segs:
|
| 172 |
+
if row_cols[2].button(
|
| 173 |
+
"🔀", key=f"sample_randomize_{currFile}_{sp}",
|
| 174 |
+
help="Try a different audio sample for this speaker",
|
| 175 |
+
):
|
| 176 |
+
randomize_speaker_clip(currFile, sp)
|
| 177 |
+
st.rerun()
|
| 178 |
+
else:
|
| 179 |
+
row_cols[1].write("—")
|
| 180 |
|
| 181 |
|
| 182 |
# ---------------------------------------------------------------------------
|
|
|
|
| 221 |
x="files", y=["One Voice", "Multi Voice", "No Voice"],
|
| 222 |
title=title),
|
| 223 |
use_container_width=True, config=cfg,
|
| 224 |
+
)
|