duongthienz commited on
Commit
da3b542
·
verified ·
1 Parent(s): a07b102

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -14
app.py CHANGED
@@ -601,18 +601,22 @@ try:
601
  st.sidebar.subheader("Rename Speakers")
602
  st.sidebar.caption("Replace SPEAKER_## labels with real names.")
603
  current_renames = st.session_state.speakerRenames[currFileIndex]
604
- for sp in speakerNames:
605
- current_label = current_renames.get(sp, "")
606
- new_name = st.sidebar.text_input(
607
- f"{sp}",
608
- value=current_label,
609
- placeholder=f"e.g. John",
610
- key=f"rename_{currFileIndex}_{sp}"
611
- )
612
- if new_name.strip():
613
- st.session_state.speakerRenames[currFileIndex][sp] = new_name.strip()
614
- elif sp in st.session_state.speakerRenames[currFileIndex]:
615
- del st.session_state.speakerRenames[currFileIndex][sp]
 
 
 
 
616
 
617
  catTypeColors = su.colorsCSS(3)
618
  allColors = su.colorsCSS(len(speakerNames)+len(st.session_state.categories))
@@ -957,8 +961,8 @@ try:
957
  st.plotly_chart(fig2_la, use_container_width=True, config=config)
958
  col6_1, col6_2 = st.columns(2)
959
  try:
960
- fig_la.write_image("ascn_bar.pdf")
961
- fig_la.write_image("ascn_bar.svg")
962
  except Exception:
963
  pass
964
  with col6_1:
 
601
  st.sidebar.subheader("Rename Speakers")
602
  st.sidebar.caption("Replace SPEAKER_## labels with real names.")
603
  current_renames = st.session_state.speakerRenames[currFileIndex]
604
+ with st.sidebar.form("rename_form"):
605
+ temp_renames = {}
606
+ for sp in speakerNames:
607
+ current_label = current_renames.get(sp, "")
608
+ temp_renames[sp] = st.text_input(
609
+ f"{sp}",
610
+ value=current_label,
611
+ placeholder="e.g. John",
612
+ )
613
+ if st.form_submit_button("Apply Names"):
614
+ for sp, new_name in temp_renames.items():
615
+ if new_name.strip():
616
+ st.session_state.speakerRenames[currFileIndex][sp] = new_name.strip()
617
+ elif sp in st.session_state.speakerRenames[currFileIndex]:
618
+ del st.session_state.speakerRenames[currFileIndex][sp]
619
+ st.rerun()
620
 
621
  catTypeColors = su.colorsCSS(3)
622
  allColors = su.colorsCSS(len(speakerNames)+len(st.session_state.categories))
 
961
  st.plotly_chart(fig2_la, use_container_width=True, config=config)
962
  col6_1, col6_2 = st.columns(2)
963
  try:
964
+ fig2_la.write_image("ascn_bar.pdf")
965
+ fig2_la.write_image("ascn_bar.svg")
966
  except Exception:
967
  pass
968
  with col6_1: