Spaces:
Runtime error
Runtime error
Merge remote-tracking branch 'upstream/master' into page_4to6_ui
Browse files- modules/whisper_modules.py +0 -1
- 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=
|
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 |
-
|
|
|
406 |
|
407 |
-
|
408 |
-
judgement_who = st.selectbox("Choose your debate theme", debate_themes)
|
409 |
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
elif judgement_who == 'Bot':
|
415 |
-
debate_history = st.session_state.bot_debate_history
|
416 |
|
417 |
-
|
|
|
418 |
|
419 |
-
|
420 |
-
|
|
|
|
|
|
|
|
|
421 |
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
|
427 |
#########################################################
|
428 |
# Page6
|
@@ -430,52 +477,77 @@ def page5():
|
|
430 |
|
431 |
def page6():
|
432 |
|
433 |
-
|
|
|
|
|
|
|
434 |
|
435 |
-
|
436 |
-
user_history = st.session_state.user_debate_history
|
437 |
|
438 |
-
|
|
|
|
|
|
|
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 |
-
|
449 |
-
|
|
|
|
|
|
|
450 |
|
451 |
-
|
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 |
-
|
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 |
-
|
|
|
465 |
|
|
|
|
|
466 |
|
467 |
-
|
468 |
-
# Page7
|
469 |
-
#########################################################
|
470 |
-
def page7():
|
471 |
-
pass
|
472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|