Unggi commited on
Commit
1aec58d
โ€ข
1 Parent(s): c52d065

whole process work! but page 6 must be upgraded

Browse files
Files changed (3) hide show
  1. audio.wav +0 -0
  2. bots/judgement_bot.py +63 -22
  3. vocal_app.py +106 -52
audio.wav CHANGED
Binary files a/audio.wav and b/audio.wav differ
 
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
@@ -9,6 +9,9 @@ from bots.judgement_bot import debate_judgement
9
  import numpy as np
10
  from collections import Counter
11
  import re
 
 
 
12
  from audiorecorder import audiorecorder
13
 
14
  config = dotenv_values(".env")
@@ -51,7 +54,7 @@ if "page2_tab" not in st.session_state:
51
  st.session_state.page2_tab = "tab1"
52
 
53
  if "total_debate_history" not in st.session_state:
54
- st.session_state.total_debate_history = ""
55
 
56
  if "user_debate_history" not in st.session_state:
57
  st.session_state.user_debate_history = []
@@ -65,6 +68,16 @@ if "user_debate_time" not in st.session_state:
65
  if "pros_and_cons" not in st.session_state:
66
  st.session_state.pros_and_cons = ""
67
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  # Initialize session state variables
70
  if 'generated' not in st.session_state:
@@ -111,9 +124,15 @@ def page2_tab_controller():
111
  def page4_controller():
112
  st.session_state.page = "Page 4"
113
 
 
 
 
114
  def page_5_6_controller():
115
  st.session_state.page = "Page 6"
116
 
 
 
 
117
  #########################################################
118
  # Page 1
119
  #########################################################
@@ -152,15 +171,13 @@ def page1():
152
  #########################################################
153
  def page2():
154
  st.header("Choose Option")
155
- option_result = st.selectbox("Choose your option", ["Total Debate", "Evaluation Only", "Analyzing Utterances"])
156
 
157
  # add controller
158
  if option_result == "Total Debate":
159
  page_control_func = page_2_3_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',
@@ -316,6 +333,9 @@ def generate_response(prompt):
316
 
317
  def page4():
318
 
 
 
 
319
  with st.sidebar:
320
  st.sidebar.title('Ask to GPT')
321
  user_input = st.sidebar.text_area(
@@ -368,23 +388,30 @@ def page4():
368
 
369
  with container:
370
  #TODO (์›…๊ธฐํ˜•) : STT ๋ถ™์ด๋Š” ๋ถ€๋ถ„
371
- audio = audiorecorder("Click to record", "Recording...")
372
 
373
- if audio:
 
374
 
375
- wav_file = open("audio.wav", "wb")
376
- wav_file.write(audio.tobytes())
377
 
378
- audio_file= open("audio.wav", "rb")
 
 
 
379
 
380
- whisper_result = openai.Audio.transcribe("whisper-1", audio_file).text
381
-
382
 
383
- with st.form(key='my_form', clear_on_submit=True):
384
- user_input = st.text_area("You:", key='input', height=100)
 
 
 
 
 
385
  submit_buttom = st.form_submit_button(label='Send')
386
 
387
- if submit_buttom and user_input:
 
388
  output = generate_response(user_input)
389
  st.session_state['user_debate_history'].append(user_input)
390
  st.session_state['bot_debate_history'].append(output)
@@ -404,6 +431,11 @@ def page4():
404
  message(st.session_state["past"][i], is_user=True, key=str(i) + '_user')
405
  message(st.session_state["generated"][i + 1], key=str(i + 1))
406
 
 
 
 
 
 
407
 
408
  print(st.session_state)
409
 
@@ -412,6 +444,10 @@ print(st.session_state)
412
  #########################################################
413
  def page5():
414
 
 
 
 
 
415
  # st.tab
416
  st.header('Total Debate Evaluation')
417
 
@@ -425,14 +461,22 @@ def page5():
425
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€๏ฟฝ๏ฟฝ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
426
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
427
 
428
- if judgement_who == 'User-Bot':
429
- debate_history = st.session_state.total_debate_history
430
- elif judgement_who == 'User':
431
- debate_history = st.session_state.user_debate_history
432
- elif judgement_who == 'Bot':
433
- debate_history = st.session_state.bot_debate_history
434
 
435
- judgement_result = debate_judgement(debate_history)
 
 
 
 
 
 
 
 
 
 
 
436
 
437
  st.write("Debate Judgement Result")
438
  st.write(judgement_result)
@@ -447,33 +491,33 @@ def page5():
447
 
448
  # ์ด ๋‹จ์–ด
449
  # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
450
- words = user_history.split()
451
  # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
452
- total_word_count = Counter(words)
453
  #total_word_count = len(user_history.split())
454
  st.write("Total Word Count: ", total_word_count)
455
 
456
  # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
457
- user_debate_time = st.session_state.user_debate_time
458
- average_word_per_time = total_word_count / user_debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
459
  st.write("Average Word Per Time: ", average_word_per_time)
460
 
461
  # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
462
- # ๋นˆ๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
463
- most_common_words = total_word_count.most_common()
464
- # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ 10๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
465
- st.write("Most Common Words: ", most_common_words[:10])
 
 
466
 
467
  # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
468
  # whisper preprocesser์—์„œ ์ฃผ๋ฉด
469
  disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
470
  # Count the disfluency words
471
- disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
472
  st.write("Disfluency Counts: ", disfluency_counts)
473
 
474
  # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
475
  # st.session_state.debate_history
476
-
477
 
478
 
479
  #########################################################
@@ -482,8 +526,10 @@ def page5():
482
 
483
  def page6():
484
 
485
- # ์—ฌ๊ธฐ์„œ User์˜ ๊ณผ๊ฑฐ ๊ธฐ๋ก์„ ๊ฒ€์ƒ‰ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์•ผ ํ•จ
486
-
 
 
487
  # st.tab
488
  st.header('Total Debate Evaluation')
489
 
@@ -497,14 +543,22 @@ def page6():
497
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
498
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
499
 
500
- if judgement_who == 'User-Bot':
501
- debate_history = st.session_state.total_debate_history
502
- elif judgement_who == 'User':
503
- debate_history = st.session_state.user_debate_history
504
- elif judgement_who == 'Bot':
505
- debate_history = st.session_state.bot_debate_history
 
 
 
 
506
 
507
- judgement_result = debate_judgement(debate_history)
 
 
 
 
508
 
509
  st.write("Debate Judgement Result")
510
  st.write(judgement_result)
@@ -519,34 +573,34 @@ def page6():
519
 
520
  # ์ด ๋‹จ์–ด
521
  # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
522
- words = user_history.split()
523
  # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
524
- total_word_count = Counter(words)
525
  #total_word_count = len(user_history.split())
526
  st.write("Total Word Count: ", total_word_count)
527
 
528
  # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
529
- user_debate_time = st.session_state.user_debate_time
530
- average_word_per_time = total_word_count / user_debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
531
  st.write("Average Word Per Time: ", average_word_per_time)
532
 
533
  # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
534
- # ๋นˆ๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
535
- most_common_words = total_word_count.most_common()
536
- # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ 10๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
537
- st.write("Most Common Words: ", most_common_words[:10])
 
 
538
 
539
  # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
540
  # whisper preprocesser์—์„œ ์ฃผ๋ฉด
541
  disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
542
  # Count the disfluency words
543
- disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
544
  st.write("Disfluency Counts: ", disfluency_counts)
545
 
546
  # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
547
  # st.session_state.debate_history
548
 
549
-
550
  ############################################
551
  # Visualization
552
  ############################################
 
9
  import numpy as np
10
  from collections import Counter
11
  import re
12
+ import math
13
+ import time
14
+
15
  from audiorecorder import audiorecorder
16
 
17
  config = dotenv_values(".env")
 
54
  st.session_state.page2_tab = "tab1"
55
 
56
  if "total_debate_history" not in st.session_state:
57
+ st.session_state.total_debate_history = []
58
 
59
  if "user_debate_history" not in st.session_state:
60
  st.session_state.user_debate_history = []
 
68
  if "pros_and_cons" not in st.session_state:
69
  st.session_state.pros_and_cons = ""
70
 
71
+ # Time session
72
+ if "start_time" not in st.session_state:
73
+ st.session_state.start_time = time.time()
74
+
75
+ if "end_time" not in st.session_state:
76
+ st.session_state.end_time = time.time()
77
+
78
+ if "debate_time" not in st.session_state:
79
+ st.session_state.debate_time = 0
80
+
81
 
82
  # Initialize session state variables
83
  if 'generated' not in st.session_state:
 
124
  def page4_controller():
125
  st.session_state.page = "Page 4"
126
 
127
+ def page_4_5_controller():
128
+ st.session_state.page = "Page 5"
129
+
130
  def page_5_6_controller():
131
  st.session_state.page = "Page 6"
132
 
133
+ def page_2_6_controller():
134
+ st.session_state.page = "Page 6"
135
+
136
  #########################################################
137
  # Page 1
138
  #########################################################
 
171
  #########################################################
172
  def page2():
173
  st.header("Choose Option")
174
+ option_result = st.selectbox("Choose your option", ["Total Debate", "Evaluation Only & Analyzing Utterances"])
175
 
176
  # add controller
177
  if option_result == "Total Debate":
178
  page_control_func = page_2_3_controller
179
+ elif option_result == "Evaluation Only & Analyzing Utterances":
180
+ page_control_func = page_2_6_controller
 
 
181
 
182
  if st.button(
183
  label='Submit all information',
 
333
 
334
  def page4():
335
 
336
+ # time
337
+ st.session_state.start_time = time.time()
338
+
339
  with st.sidebar:
340
  st.sidebar.title('Ask to GPT')
341
  user_input = st.sidebar.text_area(
 
388
 
389
  with container:
390
  #TODO (์›…๊ธฐํ˜•) : STT ๋ถ™์ด๋Š” ๋ถ€๋ถ„
 
391
 
392
+ with st.form(key='my_form', clear_on_submit=True):
393
+ audio = audiorecorder("Click to record", "Recording...")
394
 
395
+ print("audio", audio)
 
396
 
397
+ if audio != []:
398
+ user_input_exist=True
399
+ wav_file = open("audio.wav", "wb")
400
+ wav_file.write(audio.tobytes())
401
 
402
+ audio_file= open("audio.wav", "rb")
 
403
 
404
+ user_input = openai.Audio.transcribe("whisper-1", audio_file).text
405
+ else:
406
+ user_input_exist=False
407
+ user_input = "Nothing to transcribe"
408
+ print("Nothing to transcribe")
409
+
410
+ #user_input = st.text_area("You:", key='input', height=100)
411
  submit_buttom = st.form_submit_button(label='Send')
412
 
413
+ #if submit_buttom and user_input:
414
+ if submit_buttom and user_input_exist:
415
  output = generate_response(user_input)
416
  st.session_state['user_debate_history'].append(user_input)
417
  st.session_state['bot_debate_history'].append(output)
 
431
  message(st.session_state["past"][i], is_user=True, key=str(i) + '_user')
432
  message(st.session_state["generated"][i + 1], key=str(i + 1))
433
 
434
+ if st.button(
435
+ label="Next",
436
+ on_click=page_4_5_controller
437
+ ):
438
+ st.write('Information submitted successfully.')
439
 
440
  print(st.session_state)
441
 
 
444
  #########################################################
445
  def page5():
446
 
447
+ # end time
448
+ st.session_state.end_time = time.time()
449
+ st.session_state.debate_time = st.session_state.end_time - st.session_state.start_time
450
+
451
  # st.tab
452
  st.header('Total Debate Evaluation')
453
 
 
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)
 
491
 
492
  # ์ด ๋‹จ์–ด
493
  # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
 
494
  # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
495
+ total_word_count = len(user_history)
496
  #total_word_count = len(user_history.split())
497
  st.write("Total Word Count: ", total_word_count)
498
 
499
  # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
500
+ #user_debate_time = st.session_state.user_debate_time
501
+ average_word_per_time = total_word_count / st.session_state.debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
502
  st.write("Average Word Per Time: ", average_word_per_time)
503
 
504
  # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
505
+ # ๋นˆ๋„ ๊ณ„์‚ฐ
506
+ frequency = Counter(user_history)
507
+ # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ
508
+ most_common_data = frequency.most_common(10)
509
+ print(most_common_data)
510
+ st.write("Most Common Words: ", most_common_data)
511
 
512
  # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
513
  # whisper preprocesser์—์„œ ์ฃผ๋ฉด
514
  disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
515
  # Count the disfluency words
516
+ disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
517
  st.write("Disfluency Counts: ", disfluency_counts)
518
 
519
  # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
520
  # st.session_state.debate_history
 
521
 
522
 
523
  #########################################################
 
526
 
527
  def page6():
528
 
529
+ # end time
530
+ st.session_state.end_time = time.time()
531
+ st.session_state.debate_time = st.session_state.end_time - st.session_state.start_time
532
+
533
  # st.tab
534
  st.header('Total Debate Evaluation')
535
 
 
543
  # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
544
  judgement_who = st.selectbox("Choose your debate theme", debate_themes)
545
 
546
+ judgement_result = ""
547
+ if judgement_result == "":
548
+ st.write("Wait for judgement result...")
549
+
550
+ user_debate_history = "".join(
551
+ st.session_state.user_debate_history
552
+ )
553
+ bot_debate_history = "".join(
554
+ st.session_state.bot_debate_history
555
+ )
556
 
557
+ judgement_result = debate_judgement(
558
+ judgement_who,
559
+ user_debate_history,
560
+ bot_debate_history
561
+ )
562
 
563
  st.write("Debate Judgement Result")
564
  st.write(judgement_result)
 
573
 
574
  # ์ด ๋‹จ์–ด
575
  # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
 
576
  # ๊ฐ ๋‹จ์–ด์˜ ๋นˆ๋„๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.
577
+ total_word_count = len(user_history)
578
  #total_word_count = len(user_history.split())
579
  st.write("Total Word Count: ", total_word_count)
580
 
581
  # ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)
582
+ #user_debate_time = st.session_state.user_debate_time
583
+ average_word_per_time = total_word_count / st.session_state.debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
584
  st.write("Average Word Per Time: ", average_word_per_time)
585
 
586
  # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
587
+ # ๋นˆ๋„ ๊ณ„์‚ฐ
588
+ frequency = Counter(user_history)
589
+ # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ
590
+ most_common_data = frequency.most_common(10)
591
+ print(most_common_data)
592
+ st.write("Most Common Words: ", most_common_data)
593
 
594
  # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
595
  # whisper preprocesser์—์„œ ์ฃผ๋ฉด
596
  disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
597
  # Count the disfluency words
598
+ disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
599
  st.write("Disfluency Counts: ", disfluency_counts)
600
 
601
  # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
602
  # st.session_state.debate_history
603
 
 
604
  ############################################
605
  # Visualization
606
  ############################################