Spaces:
Runtime error
Runtime error
Merge remote-tracking branch 'upstream/master' into page_4to6_ui
Browse files- bots/judgement_bot.py +63 -22
- 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(
|
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
@@ -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
|
155 |
|
156 |
# add controller
|
157 |
if option_result == "Total Debate":
|
158 |
page_control_func = page_2_3_controller
|
159 |
-
|
160 |
-
|
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 |
-
|
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 |
-
|
358 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
359 |
else:
|
360 |
-
|
361 |
-
|
|
|
362 |
|
363 |
-
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
|
|
|
|
|
|
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 |
-
|
415 |
-
|
416 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 =
|
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 /
|
445 |
st.write("Average Word Per Time: ", average_word_per_time)
|
446 |
|
447 |
# 2. ๋น์ถ ๋จ์ด: ๋ฐ๋ณตํด์ ์ฌ์ฉํ๋ ๋จ์ด ๋ฆฌ์คํธ
|
448 |
-
#
|
449 |
-
|
450 |
-
# ๊ฐ์ฅ ๋น๋๊ฐ ๋์
|
451 |
-
|
|
|
|
|
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 =
|
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 |
-
#
|
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 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
|
|
|
|
|
|
|
|
492 |
|
493 |
-
judgement_result = debate_judgement(
|
|
|
|
|
|
|
|
|
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 =
|
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 /
|
517 |
st.write("Average Word Per Time: ", average_word_per_time)
|
518 |
|
519 |
# 2. ๋น์ถ ๋จ์ด: ๋ฐ๋ณตํด์ ์ฌ์ฉํ๋ ๋จ์ด ๋ฆฌ์คํธ
|
520 |
-
#
|
521 |
-
|
522 |
-
# ๊ฐ์ฅ ๋น๋๊ฐ ๋์
|
523 |
-
|
|
|
|
|
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 =
|
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 |
############################################
|