Ridealist commited on
Commit
fefe97e
โ€ข
1 Parent(s): c63094c

feat: add spinner to loading info & fix some bugs

Browse files
Files changed (1) hide show
  1. vocal_app.py +24 -25
vocal_app.py CHANGED
@@ -77,7 +77,7 @@ if "debate_time" not in st.session_state:
77
  st.session_state.debate_time = 0
78
 
79
  if "pre_audio" not in st.session_state:
80
- st.session_state.pre_audio = np.ndarray(())
81
 
82
 
83
  # Save function (placeholder)
@@ -111,7 +111,7 @@ def page_2_3_controller():
111
  def page2_tab_controller():
112
  st.session_state.page2_tab = "tab2"
113
 
114
- def page4_controller():
115
  st.session_state.page = "Page 4"
116
 
117
  def page_4_5_controller():
@@ -288,7 +288,8 @@ def page3():
288
 
289
  if start:
290
  if validate_case(case_error_message):
291
- page4_controller()
 
292
 
293
  with st.sidebar:
294
  st.sidebar.title('Ask to GPT')
@@ -394,7 +395,7 @@ def page4():
394
  # record voice
395
  audio = audiorecorder("Click to record", "Recording...")
396
  if np.array_equal(st.session_state['pre_audio'], audio):
397
- audio = np.ndarray(())
398
  print("audio", audio)
399
 
400
  #user_input = st.text_area("You:", key='input', height=100)
@@ -429,11 +430,9 @@ def page4():
429
  audio_bytes = audio_file.read()
430
  st.audio(audio_bytes, format='audio/ogg')
431
 
432
- if st.button(
433
- label="Next",
434
- on_click=page_4_5_controller
435
- ):
436
- st.write('Information submitted successfully.')
437
 
438
  print("#"*50)
439
  print(st.session_state)
@@ -461,25 +460,25 @@ def page5():
461
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
462
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
463
 
464
- judgement_result = ""
465
- if judgement_result == "":
466
- st.write("Wait for judgement result...")
467
-
468
- user_debate_history = "".join(
469
- st.session_state.user_debate_history
470
- )
471
- bot_debate_history = "".join(
472
- st.session_state.bot_debate_history
473
- )
474
 
475
- judgement_result = debate_judgement(
476
- judgement_who,
477
- user_debate_history,
478
- bot_debate_history
 
479
  )
480
 
481
- st.write("Debate Judgement Result")
482
- st.write(judgement_result)
 
 
 
 
 
 
 
483
 
484
  with tab2:
485
  st.header('Debate Analysis')
 
77
  st.session_state.debate_time = 0
78
 
79
  if "pre_audio" not in st.session_state:
80
+ st.session_state.pre_audio = np.array([])
81
 
82
 
83
  # Save function (placeholder)
 
111
  def page2_tab_controller():
112
  st.session_state.page2_tab = "tab2"
113
 
114
+ def page_3_4_controller():
115
  st.session_state.page = "Page 4"
116
 
117
  def page_4_5_controller():
 
288
 
289
  if start:
290
  if validate_case(case_error_message):
291
+ page_3_4_controller()
292
+ st.experimental_rerun()
293
 
294
  with st.sidebar:
295
  st.sidebar.title('Ask to GPT')
 
395
  # record voice
396
  audio = audiorecorder("Click to record", "Recording...")
397
  if np.array_equal(st.session_state['pre_audio'], audio):
398
+ audio = np.array([])
399
  print("audio", audio)
400
 
401
  #user_input = st.text_area("You:", key='input', height=100)
 
430
  audio_bytes = audio_file.read()
431
  st.audio(audio_bytes, format='audio/ogg')
432
 
433
+ if st.button(label="Next",
434
+ on_click=page_4_5_controller):
435
+ st.write('Information submitted successfully.')
 
 
436
 
437
  print("#"*50)
438
  print(st.session_state)
 
460
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
461
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
462
 
463
+ with st.spinner('Wait for judgement result...'):
464
+ judgement_result = ""
 
 
 
 
 
 
 
 
465
 
466
+ user_debate_history = "".join(
467
+ st.session_state.user_debate_history
468
+ )
469
+ bot_debate_history = "".join(
470
+ st.session_state.bot_debate_history
471
  )
472
 
473
+ judgement_result = debate_judgement(
474
+ judgement_who,
475
+ user_debate_history,
476
+ bot_debate_history
477
+ )
478
+
479
+ st.write("Debate Judgement Result")
480
+ st.write(judgement_result)
481
+ st.success('Done!')
482
 
483
  with tab2:
484
  st.header('Debate Analysis')