Spaces:
Runtime error
Runtime error
whole process work! but page 6 must be upgraded
Browse files- audio.wav +0 -0
- bots/judgement_bot.py +63 -22
- 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(
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
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 =
|
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 |
-
|
|
|
374 |
|
375 |
-
|
376 |
-
wav_file.write(audio.tobytes())
|
377 |
|
378 |
-
|
|
|
|
|
|
|
379 |
|
380 |
-
|
381 |
-
|
382 |
|
383 |
-
|
384 |
-
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
429 |
-
|
430 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 =
|
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 /
|
459 |
st.write("Average Word Per Time: ", average_word_per_time)
|
460 |
|
461 |
# 2. ๋น์ถ ๋จ์ด: ๋ฐ๋ณตํด์ ์ฌ์ฉํ๋ ๋จ์ด ๋ฆฌ์คํธ
|
462 |
-
#
|
463 |
-
|
464 |
-
# ๊ฐ์ฅ ๋น๋๊ฐ ๋์
|
465 |
-
|
|
|
|
|
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 =
|
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 |
-
#
|
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 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
|
|
|
|
|
|
|
|
506 |
|
507 |
-
judgement_result = debate_judgement(
|
|
|
|
|
|
|
|
|
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 =
|
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 /
|
531 |
st.write("Average Word Per Time: ", average_word_per_time)
|
532 |
|
533 |
# 2. ๋น์ถ ๋จ์ด: ๋ฐ๋ณตํด์ ์ฌ์ฉํ๋ ๋จ์ด ๋ฆฌ์คํธ
|
534 |
-
#
|
535 |
-
|
536 |
-
# ๊ฐ์ฅ ๋น๋๊ฐ ๋์
|
537 |
-
|
|
|
|
|
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 =
|
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 |
############################################
|