Ridealist commited on
Commit
ca19b5b
โ€ข
2 Parent(s): e7b338c 6140dc1

Merge remote-tracking branch 'upstream/master' into page_4to6_ui

Browse files
Files changed (2) hide show
  1. modules/whisper_modules.py +0 -1
  2. vocal_app.py +128 -58
modules/whisper_modules.py CHANGED
@@ -62,7 +62,6 @@ def debate_in_sound(audio):
62
  return response
63
 
64
 
65
-
66
  def transcribe(audio):
67
  os.rename(audio, audio + '.wav')
68
  file = open(audio + '.wav', "rb")
 
62
  return response
63
 
64
 
 
65
  def transcribe(audio):
66
  os.rename(audio, audio + '.wav')
67
  file = open(audio + '.wav', "rb")
vocal_app.py CHANGED
@@ -140,11 +140,19 @@ def page1():
140
  #########################################################
141
  def page2():
142
  st.header("Choose Option")
143
- st.selectbox("Choose your option", ["Total Debate", "Evaluation Only", "Analyzing Utterances"])
 
 
 
 
 
 
 
 
144
 
145
  if st.button(
146
  label='Submit all information',
147
- on_click=page_2_3_controller
148
  ):
149
  st.write('Information submitted successfully.')
150
 
@@ -398,31 +406,70 @@ print(st.session_state)
398
  # Page5 - Total Debate Evaluation
399
  #########################################################
400
  def page5():
401
- st.header('Debate Judgement')
402
- # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
403
- # st.session_state.debate_history
404
 
405
- debate_themes = ['User-Bot', "User", "Bot"]
 
406
 
407
- # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
408
- judgement_who = st.selectbox("Choose your debate theme", debate_themes)
409
 
410
- if judgement_who == 'User-Bot':
411
- debate_history = st.session_state.total_debate_history
412
- elif judgement_who == 'User':
413
- debate_history = st.session_state.user_debate_history
414
- elif judgement_who == 'Bot':
415
- debate_history = st.session_state.bot_debate_history
416
 
417
- judgement_result = debate_judgement(debate_history)
 
418
 
419
- st.write("Debate Judgement Result")
420
- st.write(judgement_result)
 
 
 
 
421
 
422
- st.button(
423
- label='Move to Debate Dashboard',
424
- on_click=page_5_6_controller
425
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
 
427
  #########################################################
428
  # Page6
@@ -430,52 +477,77 @@ def page5():
430
 
431
  def page6():
432
 
433
- st.header('Debate Analysis')
 
 
 
434
 
435
- # ์œ ์ €์˜ history๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฐœํ™”๋Ÿ‰, ๋นˆ์ถœ ๋‹จ์–ด, ๋ฐœํ™” ์Šต๊ด€ ์„ธ ๊ฐ€์ง€๋ฅผ ๋ถ„์„
436
- user_history = st.session_state.user_debate_history
437
 
438
- # 1. ๋ฐœํ™”๋Ÿ‰: ์ด ๋‹จ์–ด, ํ‰๏ฟฝ๏ฟฝ๏ฟฝ ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)๋ฅผ ํ‰๊ท  ๋ฐœํ™”๋Ÿ‰ ํ˜น์€ ์ฐธ๊ณ  ์ง€ํ‘œ์™€ ๋น„๊ตํ•ด ์ œ์‹œ
 
 
 
439
 
440
- # ์ด ๋‹จ์–ด
441
- # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
442
- words = user_history.split()
443
- # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
444
- total_word_count = Counter(words)
445
- #total_word_count = len(user_history.split())
446
 
447
- # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
448
- user_debate_time = st.session_state.user_debate_time
449
- average_word_per_time = total_word_count / user_debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
 
 
 
450
 
451
- # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
452
- # ๋นˆ๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
453
- most_common_words = total_word_count.most_common()
454
- # for word, count in most_common_words:
455
- # print(f"'{word}': {count}")
456
 
457
- # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
458
- # ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€์„ ์ •๊ทœํ‘œํ˜„์‹์œผ๋กœ ์ฐพ์•„๋‚ด๊ธฐ
459
- # whisper preprocesser์—์„œ ์ฃผ๋ฉด
460
- disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
461
- # Count the disfluency words
462
- disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
463
 
464
- pass
 
465
 
 
 
466
 
467
- #########################################################
468
- # Page7
469
- #########################################################
470
- def page7():
471
- pass
472
 
 
 
 
 
 
 
 
473
 
474
- #########################################################
475
- # Page8
476
- #########################################################
477
- def page8():
478
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
479
 
480
 
481
 
@@ -489,8 +561,6 @@ pages = {
489
  "Page 4": page4, # Evaluation Only
490
  "Page 5": page5, # Analyzing Utterances
491
  "Page 6": page6,
492
- "Page 7": page7,
493
- "Page 8": page8
494
  }
495
 
496
  selection = st.session_state.page
 
140
  #########################################################
141
  def page2():
142
  st.header("Choose Option")
143
+ option_result = st.selectbox("Choose your option", ["Total Debate", "Evaluation Only", "Analyzing Utterances"])
144
+
145
+ # add controller
146
+ if option_result == "Total Debate":
147
+ page_control_func = page_2_3_controller
148
+ elif option_result == "Evaluation Only":
149
+ page_control_func = page_2_7_controller
150
+ elif option_result == "Analyzing Utterances":
151
+ page_control_func = page_2_8_controller
152
 
153
  if st.button(
154
  label='Submit all information',
155
+ on_click=page_control_func
156
  ):
157
  st.write('Information submitted successfully.')
158
 
 
406
  # Page5 - Total Debate Evaluation
407
  #########################################################
408
  def page5():
 
 
 
409
 
410
+ # st.tab
411
+ st.header('Total Debate Evaluation')
412
 
413
+ tab1, tab2 = st.tabs(['Debate Judgement', 'Debate Analysis'])
 
414
 
415
+ with tab1:
416
+ st.header("Debate Evaluation")
417
+
418
+ debate_themes = ['User-Bot', "User", "Bot"]
 
 
419
 
420
+ # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
421
+ judgement_who = st.selectbox("Choose your debate theme", debate_themes)
422
 
423
+ if judgement_who == 'User-Bot':
424
+ debate_history = st.session_state.total_debate_history
425
+ elif judgement_who == 'User':
426
+ debate_history = st.session_state.user_debate_history
427
+ elif judgement_who == 'Bot':
428
+ debate_history = st.session_state.bot_debate_history
429
 
430
+ judgement_result = debate_judgement(debate_history)
431
+
432
+ st.write("Debate Judgement Result")
433
+ st.write(judgement_result)
434
+
435
+ with tab2:
436
+ st.header('Debate Analysis')
437
+
438
+ # ์œ ์ €์˜ history๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฐœํ™”๋Ÿ‰, ๋นˆ์ถœ ๋‹จ์–ด, ๋ฐœํ™” ์Šต๊ด€ ์„ธ ๊ฐ€์ง€๋ฅผ ๋ถ„์„
439
+ user_history = st.session_state.user_debate_history
440
+
441
+ # 1. ๋ฐœํ™”๋Ÿ‰: ์ด ๋‹จ์–ด, ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)๋ฅผ ํ‰๊ท  ๋ฐœํ™”๋Ÿ‰ ํ˜น์€ ์ฐธ๊ณ  ์ง€ํ‘œ์™€ ๋น„๊ตํ•ด ์ œ์‹œ
442
+
443
+ # ์ด ๋‹จ์–ด
444
+ # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
445
+ words = user_history.split()
446
+ # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
447
+ total_word_count = Counter(words)
448
+ #total_word_count = len(user_history.split())
449
+ st.write("Total Word Count: ", total_word_count)
450
+
451
+ # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
452
+ user_debate_time = st.session_state.user_debate_time
453
+ average_word_per_time = total_word_count / user_debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
454
+ st.write("Average Word Per Time: ", average_word_per_time)
455
+
456
+ # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
457
+ # ๋นˆ๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
458
+ most_common_words = total_word_count.most_common()
459
+ # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ 10๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
460
+ st.write("Most Common Words: ", most_common_words[:10])
461
+
462
+ # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
463
+ # whisper preprocesser์—์„œ ์ฃผ๋ฉด
464
+ disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
465
+ # Count the disfluency words
466
+ disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
467
+ st.write("Disfluency Counts: ", disfluency_counts)
468
+
469
+ # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
470
+ # st.session_state.debate_history
471
+
472
+
473
 
474
  #########################################################
475
  # Page6
 
477
 
478
  def page6():
479
 
480
+ # ์—ฌ๊ธฐ์„œ User์˜ ๊ณผ๊ฑฐ ๊ธฐ๋ก์„ ๊ฒ€์ƒ‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์•ผ ํ•จ
481
+
482
+ # st.tab
483
+ st.header('Total Debate Evaluation')
484
 
485
+ tab1, tab2 = st.tabs(['Debate Judgement', 'Debate Analysis'])
 
486
 
487
+ with tab1:
488
+ st.header("Debate Evaluation")
489
+
490
+ debate_themes = ['User-Bot', "User", "Bot"]
491
 
492
+ # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
493
+ judgement_who = st.selectbox("Choose your debate theme", debate_themes)
 
 
 
 
494
 
495
+ if judgement_who == 'User-Bot':
496
+ debate_history = st.session_state.total_debate_history
497
+ elif judgement_who == 'User':
498
+ debate_history = st.session_state.user_debate_history
499
+ elif judgement_who == 'Bot':
500
+ debate_history = st.session_state.bot_debate_history
501
 
502
+ judgement_result = debate_judgement(debate_history)
 
 
 
 
503
 
504
+ st.write("Debate Judgement Result")
505
+ st.write(judgement_result)
 
 
 
 
506
 
507
+ with tab2:
508
+ st.header('Debate Analysis')
509
 
510
+ # ์œ ์ €์˜ history๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฐœํ™”๋Ÿ‰, ๋นˆ์ถœ ๋‹จ์–ด, ๋ฐœํ™” ์Šต๊ด€ ์„ธ ๊ฐ€์ง€๋ฅผ ๋ถ„์„
511
+ user_history = st.session_state.user_debate_history
512
 
513
+ # 1. ๋ฐœํ™”๋Ÿ‰: ์ด ๋‹จ์–ด, ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)๋ฅผ ํ‰๊ท  ๋ฐœํ™”๋Ÿ‰ ํ˜น์€ ์ฐธ๊ณ  ์ง€ํ‘œ์™€ ๋น„๊ตํ•ด ์ œ์‹œ
 
 
 
 
514
 
515
+ # ์ด ๋‹จ์–ด
516
+ # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
517
+ words = user_history.split()
518
+ # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
519
+ total_word_count = Counter(words)
520
+ #total_word_count = len(user_history.split())
521
+ st.write("Total Word Count: ", total_word_count)
522
 
523
+ # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
524
+ user_debate_time = st.session_state.user_debate_time
525
+ average_word_per_time = total_word_count / user_debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
526
+ st.write("Average Word Per Time: ", average_word_per_time)
527
+
528
+ # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
529
+ # ๋นˆ๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
530
+ most_common_words = total_word_count.most_common()
531
+ # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ 10๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
532
+ st.write("Most Common Words: ", most_common_words[:10])
533
+
534
+ # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
535
+ # whisper preprocesser์—์„œ ์ฃผ๋ฉด
536
+ disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
537
+ # Count the disfluency words
538
+ disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
539
+ st.write("Disfluency Counts: ", disfluency_counts)
540
+
541
+ # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
542
+ # st.session_state.debate_history
543
+
544
+
545
+ ############################################
546
+ # Visualization
547
+ ############################################
548
+
549
+ # ์ด์ „์— ๊ธฐ๋ก๋œ ๊ฐ’์ด ์žˆ๋‹ค๋ฉด, ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฝ๋‹ˆ๋‹ค.
550
+ # ์ด์ „์— ๊ธฐ๋ก๋œ ๊ฐ’์ด ์—†๋‹ค๋ฉด, ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฌ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
551
 
552
 
553
 
 
561
  "Page 4": page4, # Evaluation Only
562
  "Page 5": page5, # Analyzing Utterances
563
  "Page 6": page6,
 
 
564
  }
565
 
566
  selection = st.session_state.page