Ridealist commited on
Commit
7ede674
โ€ข
2 Parent(s): 5b7bee5 1aec58d

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

Browse files
Files changed (2) hide show
  1. bots/judgement_bot.py +63 -22
  2. vocal_app.py +112 -66
bots/judgement_bot.py CHANGED
@@ -1,27 +1,68 @@
1
  from modules.gpt_modules import gpt_call
2
  from langchain.prompts import PromptTemplate
3
 
4
- def debate_judgement(debate_history):
5
-
6
- judgement_prompt = "\n".join([
7
- "!!Instruction!",
8
- "You are now the judge of this debate. Evaluate the debate according to the rules below.",
9
- "Rule 1. Decide between the USER and BOT.",
10
- "Rule 2. Summarize the debate as a whole and what each debater said.",
11
- "Rule 3. For each debater, explain what was persuasive and what made the differnce between winning and losing.",
12
- ])
13
-
14
- judgement_prompt_template = PromptTemplate(
15
- input_variables=["prompt"],
16
- template="\n".join([
17
- debate_history,
18
- judgement_prompt,
19
- "Judgement: "
20
- ])
21
- )
22
- judgement_bot_prompt = judgement_prompt_template.format(
23
- prompt=""
24
- )
25
- bot_response = gpt_call(judgement_bot_prompt)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  return bot_response
 
1
  from modules.gpt_modules import gpt_call
2
  from langchain.prompts import PromptTemplate
3
 
4
+ def debate_judgement(
5
+ judgement_who,
6
+ user_debate_history,
7
+ bot_debate_history
8
+ ):
9
+
10
+ if judgement_who == 'User-Bot':
11
+
12
+ judgement_prompt_preset = "\n".join([
13
+ "!!Instruction!",
14
+ "You are now the judge of this debate. Evaluate the debate according to the rules below.",
15
+ "Rule 1. Decide between the USER and BOT.",
16
+ "Rule 2. Summarize the debate as a whole and what each debater said.",
17
+ "Rule 3. For each debater, explain what was persuasive and what made the differnce between winning and losing.",
18
+ ])
19
+
20
+ judgement_prompt = "\n".join([
21
+ judgement_prompt_preset,
22
+ "User: " + user_debate_history,
23
+ "Bot: " + bot_debate_history,
24
+ "Judgement must be logical with paragraphs.",
25
+ "Do not show Rule",
26
+ "Write judgement below.",
27
+ "Judgement: "
28
+ ])
29
+
30
+ elif judgement_who == 'User':
31
+
32
+ judgement_prompt_preset = "\n".join([
33
+ "!!Instruction!",
34
+ "You are now the judge of this debate. Evaluate the debate according to the rules below.",
35
+ "Rule 1. Summarize the debate as a whole and each said.",
36
+ "Rule 2. Explain what was persuasive and what made the differnce between winning and losing.",
37
+ ])
38
+
39
+ judgement_prompt = "\n".join([
40
+ judgement_prompt_preset,
41
+ "User: " + user_debate_history,
42
+ "Judgement must be logical with paragraphs.",
43
+ "Do not show Rule",
44
+ "Write judgement below.",
45
+ "Judgement: "
46
+ ])
47
+
48
+ elif judgement_who == 'Bot':
49
+
50
+ judgement_prompt_preset = "\n".join([
51
+ "!!Instruction!",
52
+ "You are now the judge of this debate. Evaluate the debate according to the rules below.",
53
+ "Rule 1. Summarize the debate as a whole and each said.",
54
+ "Rule 2. Explain what was persuasive and what made the differnce between winning and losing.",
55
+ ])
56
+
57
+ judgement_prompt = "\n".join([
58
+ judgement_prompt_preset,
59
+ "Bot: " + bot_debate_history,
60
+ "Judgement must be logical with paragraphs.",
61
+ "Do not show Rule",
62
+ "Write judgement below.",
63
+ "Judgement: "
64
+ ])
65
+
66
+ bot_response = gpt_call(judgement_prompt)
67
 
68
  return bot_response
vocal_app.py CHANGED
@@ -8,8 +8,11 @@ from streamlit_chat import message
8
  from dotenv import dotenv_values
9
  from bots.judgement_bot import debate_judgement
10
  from collections import Counter
 
 
 
 
11
  from audiorecorder import audiorecorder
12
- from st_custom_components import st_audiorec
13
 
14
  # modules
15
  from modules.gpt_modules import gpt_call
@@ -64,6 +67,18 @@ if "user_debate_time" not in st.session_state:
64
  if "pros_and_cons" not in st.session_state:
65
  st.session_state.pros_and_cons = ""
66
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  if 'generated' not in st.session_state:
68
  st.session_state['generated'] = []
69
 
@@ -110,9 +125,15 @@ def page2_tab_controller():
110
  def page4_controller():
111
  st.session_state.page = "Page 4"
112
 
 
 
 
113
  def page_5_6_controller():
114
  st.session_state.page = "Page 6"
115
 
 
 
 
116
  #########################################################
117
  # Page 1
118
  #########################################################
@@ -151,16 +172,13 @@ def page1():
151
  #########################################################
152
  def page2():
153
  st.header("Choose Option")
154
- option_result = st.selectbox("Choose your option", ["Total Debate", "Evaluation Only", "Analyzing Utterances"])
155
 
156
  # add controller
157
  if option_result == "Total Debate":
158
  page_control_func = page_2_3_controller
159
- #TODO page_2_7_controller, page_2_8_controller ๋งŒ๋“ค๊ธฐ!
160
- # elif option_result == "Evaluation Only":
161
- # page_control_func = page_2_7_controller
162
- # elif option_result == "Analyzing Utterances":
163
- # page_control_func = page_2_8_controller
164
 
165
  if st.button(
166
  label='Submit all information',
@@ -293,6 +311,9 @@ def generate_response(prompt):
293
 
294
  def page4():
295
 
 
 
 
296
  with st.sidebar:
297
  st.sidebar.title('Ask to GPT')
298
  user_input = st.sidebar.text_area(
@@ -336,31 +357,30 @@ def page4():
336
 
337
  with container:
338
  #TODO (์›…๊ธฐํ˜•) : STT ๋ถ™์ด๋Š” ๋ถ€๋ถ„
339
- # audio_data = st_audiorec()
340
- audio_data = audiorecorder("Click to record", "Recording...")
341
-
342
- if audio_data is not None:
343
- wav_file = open("audio.wav", "wb")
344
- wav_file.write(audio_data.tobytes())
345
- wav_file.close()
346
-
347
- with open("audio.wav", "rb") as audio_file:
348
- whisper_result = openai.Audio.transcribe(
349
- model = "whisper-1",
350
- file = audio_file,
351
- response_format = "text",
352
- language = "en"
353
- )
354
- print(whisper_result)
355
-
356
  with st.form(key='my_form', clear_on_submit=True):
357
- if whisper_result:
358
- user_input = whisper_result
 
 
 
 
 
 
 
 
 
 
359
  else:
360
- user_input = st.text_area("You:", key='input', height=100)
361
- submit_buttom = st.form_submit_button(label='Send')
 
362
 
363
- if submit_buttom and user_input:
 
 
 
 
364
  output = generate_response(user_input)
365
  st.session_state['user_debate_history'].append(user_input)
366
  st.session_state['bot_debate_history'].append(output)
@@ -387,7 +407,11 @@ def page4():
387
 
388
  message(st.session_state["generated"][i + 1], key=str(i + 1))
389
 
390
- #TODO ์ „์ฒด ์œ ์ €๊ฐ€ ๋ฐœํ™”ํ•œ ์‹œ๊ฐ„ ๊ธฐ๋กํ•˜๊ธฐ -> ์„ธ์…˜์— ์ €์žฅ
 
 
 
 
391
 
392
  print("#"*50)
393
  print(st.session_state)
@@ -398,6 +422,10 @@ print("#"*50)
398
  #########################################################
399
  def page5():
400
 
 
 
 
 
401
  # st.tab
402
  st.header('Total Debate Evaluation')
403
 
@@ -411,14 +439,22 @@ def page5():
411
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
412
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
413
 
414
- if judgement_who == 'User-Bot':
415
- debate_history = st.session_state.total_debate_history
416
- elif judgement_who == 'User':
417
- debate_history = st.session_state.user_debate_history
418
- elif judgement_who == 'Bot':
419
- debate_history = st.session_state.bot_debate_history
420
 
421
- judgement_result = debate_judgement(debate_history)
 
 
 
 
 
 
 
 
 
 
 
422
 
423
  st.write("Debate Judgement Result")
424
  st.write(judgement_result)
@@ -433,33 +469,33 @@ def page5():
433
 
434
  # ์ด ๋‹จ์–ด
435
  # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
436
- words = user_history.split()
437
  # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
438
- total_word_count = Counter(words)
439
  #total_word_count = len(user_history.split())
440
  st.write("Total Word Count: ", total_word_count)
441
 
442
  # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
443
- user_debate_time = st.session_state.user_debate_time
444
- average_word_per_time = total_word_count / user_debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
445
  st.write("Average Word Per Time: ", average_word_per_time)
446
 
447
  # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
448
- # ๋นˆ๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
449
- most_common_words = total_word_count.most_common()
450
- # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ 10๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
451
- st.write("Most Common Words: ", most_common_words[:10])
 
 
452
 
453
  # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
454
  # whisper preprocesser์—์„œ ์ฃผ๋ฉด
455
  disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
456
  # Count the disfluency words
457
- disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
458
  st.write("Disfluency Counts: ", disfluency_counts)
459
 
460
  # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
461
  # st.session_state.debate_history
462
-
463
 
464
 
465
  #########################################################
@@ -468,8 +504,10 @@ def page5():
468
 
469
  def page6():
470
 
471
- # ์—ฌ๊ธฐ์„œ User์˜ ๊ณผ๊ฑฐ ๊ธฐ๋ก์„ ๊ฒ€์ƒ‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์•ผ ํ•จ
472
-
 
 
473
  # st.tab
474
  st.header('Total Debate Evaluation')
475
 
@@ -483,14 +521,22 @@ def page6():
483
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
484
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
485
 
486
- if judgement_who == 'User-Bot':
487
- debate_history = st.session_state.total_debate_history
488
- elif judgement_who == 'User':
489
- debate_history = st.session_state.user_debate_history
490
- elif judgement_who == 'Bot':
491
- debate_history = st.session_state.bot_debate_history
 
 
 
 
492
 
493
- judgement_result = debate_judgement(debate_history)
 
 
 
 
494
 
495
  st.write("Debate Judgement Result")
496
  st.write(judgement_result)
@@ -505,34 +551,34 @@ def page6():
505
 
506
  # ์ด ๋‹จ์–ด
507
  # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
508
- words = user_history.split()
509
  # ๊ฐ ๋‹จ์–ด์˜ ๏ฟฝ๏ฟฝ๏ฟฝ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
510
- total_word_count = Counter(words)
511
  #total_word_count = len(user_history.split())
512
  st.write("Total Word Count: ", total_word_count)
513
 
514
  # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
515
- user_debate_time = st.session_state.user_debate_time
516
- average_word_per_time = total_word_count / user_debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
517
  st.write("Average Word Per Time: ", average_word_per_time)
518
 
519
  # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
520
- # ๋นˆ๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
521
- most_common_words = total_word_count.most_common()
522
- # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ 10๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
523
- st.write("Most Common Words: ", most_common_words[:10])
 
 
524
 
525
  # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
526
  # whisper preprocesser์—์„œ ์ฃผ๋ฉด
527
  disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
528
  # Count the disfluency words
529
- disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
530
  st.write("Disfluency Counts: ", disfluency_counts)
531
 
532
  # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
533
  # st.session_state.debate_history
534
 
535
-
536
  ############################################
537
  # Visualization
538
  ############################################
 
8
  from dotenv import dotenv_values
9
  from bots.judgement_bot import debate_judgement
10
  from collections import Counter
11
+ import re
12
+ import math
13
+ import time
14
+
15
  from audiorecorder import audiorecorder
 
16
 
17
  # modules
18
  from modules.gpt_modules import gpt_call
 
67
  if "pros_and_cons" not in st.session_state:
68
  st.session_state.pros_and_cons = ""
69
 
70
+ # Time session
71
+ if "start_time" not in st.session_state:
72
+ st.session_state.start_time = time.time()
73
+
74
+ if "end_time" not in st.session_state:
75
+ st.session_state.end_time = time.time()
76
+
77
+ if "debate_time" not in st.session_state:
78
+ st.session_state.debate_time = 0
79
+
80
+
81
+ # Initialize session state variables
82
  if 'generated' not in st.session_state:
83
  st.session_state['generated'] = []
84
 
 
125
  def page4_controller():
126
  st.session_state.page = "Page 4"
127
 
128
+ def page_4_5_controller():
129
+ st.session_state.page = "Page 5"
130
+
131
  def page_5_6_controller():
132
  st.session_state.page = "Page 6"
133
 
134
+ def page_2_6_controller():
135
+ st.session_state.page = "Page 6"
136
+
137
  #########################################################
138
  # Page 1
139
  #########################################################
 
172
  #########################################################
173
  def page2():
174
  st.header("Choose Option")
175
+ option_result = st.selectbox("Choose your option", ["Total Debate", "Evaluation Only & Analyzing Utterances"])
176
 
177
  # add controller
178
  if option_result == "Total Debate":
179
  page_control_func = page_2_3_controller
180
+ elif option_result == "Evaluation Only & Analyzing Utterances":
181
+ page_control_func = page_2_6_controller
 
 
 
182
 
183
  if st.button(
184
  label='Submit all information',
 
311
 
312
  def page4():
313
 
314
+ # time
315
+ st.session_state.start_time = time.time()
316
+
317
  with st.sidebar:
318
  st.sidebar.title('Ask to GPT')
319
  user_input = st.sidebar.text_area(
 
357
 
358
  with container:
359
  #TODO (์›…๊ธฐํ˜•) : STT ๋ถ™์ด๋Š” ๋ถ€๋ถ„
360
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  with st.form(key='my_form', clear_on_submit=True):
362
+ audio = audiorecorder("Click to record", "Recording...")
363
+
364
+ print("audio", audio)
365
+
366
+ if audio != []:
367
+ user_input_exist=True
368
+ wav_file = open("audio.wav", "wb")
369
+ wav_file.write(audio.tobytes())
370
+
371
+ audio_file= open("audio.wav", "rb")
372
+
373
+ user_input = openai.Audio.transcribe("whisper-1", audio_file).text
374
  else:
375
+ user_input_exist=False
376
+ user_input = "Nothing to transcribe"
377
+ print("Nothing to transcribe")
378
 
379
+ #user_input = st.text_area("You:", key='input', height=100)
380
+ submit_buttom = st.form_submit_button(label='Send')
381
+
382
+ #if submit_buttom and user_input:
383
+ if submit_buttom and user_input_exist:
384
  output = generate_response(user_input)
385
  st.session_state['user_debate_history'].append(user_input)
386
  st.session_state['bot_debate_history'].append(output)
 
407
 
408
  message(st.session_state["generated"][i + 1], key=str(i + 1))
409
 
410
+ if st.button(
411
+ label="Next",
412
+ on_click=page_4_5_controller
413
+ ):
414
+ st.write('Information submitted successfully.')
415
 
416
  print("#"*50)
417
  print(st.session_state)
 
422
  #########################################################
423
  def page5():
424
 
425
+ # end time
426
+ st.session_state.end_time = time.time()
427
+ st.session_state.debate_time = st.session_state.end_time - st.session_state.start_time
428
+
429
  # st.tab
430
  st.header('Total Debate Evaluation')
431
 
 
439
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
440
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
441
 
442
+ judgement_result = ""
443
+ if judgement_result == "":
444
+ st.write("Wait for judgement result...")
 
 
 
445
 
446
+ user_debate_history = "".join(
447
+ st.session_state.user_debate_history
448
+ )
449
+ bot_debate_history = "".join(
450
+ st.session_state.bot_debate_history
451
+ )
452
+
453
+ judgement_result = debate_judgement(
454
+ judgement_who,
455
+ user_debate_history,
456
+ bot_debate_history
457
+ )
458
 
459
  st.write("Debate Judgement Result")
460
  st.write(judgement_result)
 
469
 
470
  # ์ด ๋‹จ์–ด
471
  # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
 
472
  # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
473
+ total_word_count = len(user_history)
474
  #total_word_count = len(user_history.split())
475
  st.write("Total Word Count: ", total_word_count)
476
 
477
  # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
478
+ #user_debate_time = st.session_state.user_debate_time
479
+ average_word_per_time = total_word_count / st.session_state.debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
480
  st.write("Average Word Per Time: ", average_word_per_time)
481
 
482
  # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
483
+ # ๋นˆ๋„ ๊ณ„์‚ฐ
484
+ frequency = Counter(user_history)
485
+ # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ
486
+ most_common_data = frequency.most_common(10)
487
+ print(most_common_data)
488
+ st.write("Most Common Words: ", most_common_data)
489
 
490
  # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
491
  # whisper preprocesser์—์„œ ์ฃผ๋ฉด
492
  disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
493
  # Count the disfluency words
494
+ disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
495
  st.write("Disfluency Counts: ", disfluency_counts)
496
 
497
  # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
498
  # st.session_state.debate_history
 
499
 
500
 
501
  #########################################################
 
504
 
505
  def page6():
506
 
507
+ # end time
508
+ st.session_state.end_time = time.time()
509
+ st.session_state.debate_time = st.session_state.end_time - st.session_state.start_time
510
+
511
  # st.tab
512
  st.header('Total Debate Evaluation')
513
 
 
521
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
522
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
523
 
524
+ judgement_result = ""
525
+ if judgement_result == "":
526
+ st.write("Wait for judgement result...")
527
+
528
+ user_debate_history = "".join(
529
+ st.session_state.user_debate_history
530
+ )
531
+ bot_debate_history = "".join(
532
+ st.session_state.bot_debate_history
533
+ )
534
 
535
+ judgement_result = debate_judgement(
536
+ judgement_who,
537
+ user_debate_history,
538
+ bot_debate_history
539
+ )
540
 
541
  st.write("Debate Judgement Result")
542
  st.write(judgement_result)
 
551
 
552
  # ์ด ๋‹จ์–ด
553
  # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
 
554
  # ๊ฐ ๋‹จ์–ด์˜ ๏ฟฝ๏ฟฝ๏ฟฝ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
555
+ total_word_count = len(user_history)
556
  #total_word_count = len(user_history.split())
557
  st.write("Total Word Count: ", total_word_count)
558
 
559
  # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
560
+ #user_debate_time = st.session_state.user_debate_time
561
+ average_word_per_time = total_word_count / st.session_state.debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
562
  st.write("Average Word Per Time: ", average_word_per_time)
563
 
564
  # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
565
+ # ๋นˆ๋„ ๊ณ„์‚ฐ
566
+ frequency = Counter(user_history)
567
+ # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ
568
+ most_common_data = frequency.most_common(10)
569
+ print(most_common_data)
570
+ st.write("Most Common Words: ", most_common_data)
571
 
572
  # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
573
  # whisper preprocesser์—์„œ ์ฃผ๋ฉด
574
  disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
575
  # Count the disfluency words
576
+ disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
577
  st.write("Disfluency Counts: ", disfluency_counts)
578
 
579
  # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
580
  # st.session_state.debate_history
581
 
 
582
  ############################################
583
  # Visualization
584
  ############################################