Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update autofill function
Browse files
ui.py
CHANGED
|
@@ -145,7 +145,7 @@ def render_data_table(tableDF, speakerNames, raw_to_display, currFile):
|
|
| 145 |
# ---------------------------------------------------------------------------
|
| 146 |
|
| 147 |
def render_speaker_samples_tab(speakerNames, raw_to_display, currFile):
|
| 148 |
-
"""Render a table: Speaker (with inline ✎ rename +
|
| 149 |
file_samples = st.session_state.speakerClips.get(currFile, {})
|
| 150 |
has_waveform = currFile in st.session_state.speakerWaveforms
|
| 151 |
has_samples = bool(file_samples)
|
|
@@ -153,9 +153,9 @@ def render_speaker_samples_tab(speakerNames, raw_to_display, currFile):
|
|
| 153 |
# Per-speaker editing toggle: {(currFile, sp): True}
|
| 154 |
if "inline_rename_active" not in st.session_state:
|
| 155 |
st.session_state.inline_rename_active = {}
|
| 156 |
-
#
|
| 157 |
-
if "
|
| 158 |
-
st.session_state.
|
| 159 |
|
| 160 |
# Header
|
| 161 |
header_cols = st.columns([3, 3, 1])
|
|
@@ -179,25 +179,40 @@ def render_speaker_samples_tab(speakerNames, raw_to_display, currFile):
|
|
| 179 |
input_key = f"inline_rename_input_{currFile}_{sp}"
|
| 180 |
confirm_key = f"inline_rename_confirm_{currFile}_{sp}"
|
| 181 |
cancel_key = f"inline_rename_cancel_{currFile}_{sp}"
|
| 182 |
-
|
| 183 |
-
# Autofill suggestion: prefer existing name, then last confirmed name
|
| 184 |
-
current_val = display_name if display_name != sp else ""
|
| 185 |
-
suggestion = current_val or st.session_state.inline_rename_last
|
| 186 |
|
| 187 |
with row_cols[0]:
|
| 188 |
new_name = st.text_input(
|
| 189 |
"Rename",
|
| 190 |
-
value=
|
| 191 |
key=input_key,
|
| 192 |
label_visibility="collapsed",
|
| 193 |
-
placeholder=
|
| 194 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
btn_col1, btn_col2 = st.columns(2)
|
| 196 |
if btn_col1.button("✓", key=confirm_key, help="Confirm rename"):
|
| 197 |
-
confirmed = new_name.strip()
|
| 198 |
-
apply_inline_rename(currFile, sp, confirmed)
|
| 199 |
if confirmed:
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
| 201 |
st.session_state.inline_rename_active[edit_key] = False
|
| 202 |
st.rerun()
|
| 203 |
if btn_col2.button("✕", key=cancel_key, help="Cancel"):
|
|
|
|
| 145 |
# ---------------------------------------------------------------------------
|
| 146 |
|
| 147 |
def render_speaker_samples_tab(speakerNames, raw_to_display, currFile):
|
| 148 |
+
"""Render a table: Speaker (with inline ✎ rename + history suggestions) | Audio Sample | ↺ 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)
|
|
|
|
| 153 |
# Per-speaker editing toggle: {(currFile, sp): True}
|
| 154 |
if "inline_rename_active" not in st.session_state:
|
| 155 |
st.session_state.inline_rename_active = {}
|
| 156 |
+
# Ordered list of all confirmed rename names (deduped, insertion order)
|
| 157 |
+
if "inline_rename_history" not in st.session_state:
|
| 158 |
+
st.session_state.inline_rename_history = []
|
| 159 |
|
| 160 |
# Header
|
| 161 |
header_cols = st.columns([3, 3, 1])
|
|
|
|
| 179 |
input_key = f"inline_rename_input_{currFile}_{sp}"
|
| 180 |
confirm_key = f"inline_rename_confirm_{currFile}_{sp}"
|
| 181 |
cancel_key = f"inline_rename_cancel_{currFile}_{sp}"
|
| 182 |
+
fill_prefix = f"inline_rename_fill_{currFile}_{sp}"
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
with row_cols[0]:
|
| 185 |
new_name = st.text_input(
|
| 186 |
"Rename",
|
| 187 |
+
value=display_name if display_name != sp else "",
|
| 188 |
key=input_key,
|
| 189 |
label_visibility="collapsed",
|
| 190 |
+
placeholder=f"Rename {sp}…",
|
| 191 |
)
|
| 192 |
+
|
| 193 |
+
# Clickable history suggestions
|
| 194 |
+
history = st.session_state.inline_rename_history
|
| 195 |
+
if history:
|
| 196 |
+
st.caption("Quick fill:")
|
| 197 |
+
fill_cols = st.columns(len(history))
|
| 198 |
+
for hi, past_name in enumerate(history):
|
| 199 |
+
if fill_cols[hi].button(
|
| 200 |
+
past_name,
|
| 201 |
+
key=f"{fill_prefix}_{hi}",
|
| 202 |
+
use_container_width=True,
|
| 203 |
+
):
|
| 204 |
+
apply_inline_rename(currFile, sp, past_name)
|
| 205 |
+
st.session_state.inline_rename_active[edit_key] = False
|
| 206 |
+
st.rerun()
|
| 207 |
+
|
| 208 |
btn_col1, btn_col2 = st.columns(2)
|
| 209 |
if btn_col1.button("✓", key=confirm_key, help="Confirm rename"):
|
| 210 |
+
confirmed = new_name.strip()
|
|
|
|
| 211 |
if confirmed:
|
| 212 |
+
apply_inline_rename(currFile, sp, confirmed)
|
| 213 |
+
# Add to history if not already present
|
| 214 |
+
if confirmed not in st.session_state.inline_rename_history:
|
| 215 |
+
st.session_state.inline_rename_history.append(confirmed)
|
| 216 |
st.session_state.inline_rename_active[edit_key] = False
|
| 217 |
st.rerun()
|
| 218 |
if btn_col2.button("✕", key=cancel_key, help="Cancel"):
|