Spaces:
Runtime error
Runtime error
codingchild
commited on
Commit
โข
6140dc1
1
Parent(s):
8ae9a20
change page
Browse files- vocal_app.py +110 -92
vocal_app.py
CHANGED
@@ -85,12 +85,6 @@ def page2_tab_controller():
|
|
85 |
def page_5_6_controller():
|
86 |
st.session_state.page = "Page 6"
|
87 |
|
88 |
-
def page_2_7_controller():
|
89 |
-
st.session_state.page = "Page 7"
|
90 |
-
|
91 |
-
def page_2_8_controller():
|
92 |
-
st.session_state.page = "Page 8"
|
93 |
-
|
94 |
#########################################################
|
95 |
# Page 1
|
96 |
#########################################################
|
@@ -275,124 +269,150 @@ def page4():
|
|
275 |
# Page5 - Total Debate Evaluation
|
276 |
#########################################################
|
277 |
def page5():
|
278 |
-
st.header('Debate Judgement')
|
279 |
-
# ์ ์ ์ ๋ด์ ๋ํ ๋ฐ์ดํฐ๊ฐ ์ธ์
์ ๋จ์์์
|
280 |
-
# st.session_state.debate_history
|
281 |
|
282 |
-
|
|
|
283 |
|
284 |
-
|
285 |
-
judgement_who = st.selectbox("Choose your debate theme", debate_themes)
|
286 |
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
elif judgement_who == 'Bot':
|
292 |
-
debate_history = st.session_state.bot_debate_history
|
293 |
|
294 |
-
|
|
|
295 |
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
|
|
298 |
|
299 |
-
|
300 |
-
label='Move to Debate Dashboard',
|
301 |
-
on_click=page_5_6_controller
|
302 |
-
)
|
303 |
|
304 |
-
|
305 |
-
|
306 |
-
#########################################################
|
307 |
|
308 |
-
|
|
|
309 |
|
310 |
-
|
|
|
311 |
|
312 |
-
|
313 |
-
user_history = st.session_state.user_debate_history
|
314 |
|
315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
total_word_count = Counter(words)
|
322 |
-
#total_word_count = len(user_history.split())
|
323 |
-
st.write("Total Word Count: ", total_word_count)
|
324 |
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
|
|
329 |
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
|
|
335 |
|
336 |
-
|
337 |
-
|
338 |
-
disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
|
339 |
-
# Count the disfluency words
|
340 |
-
disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
|
341 |
-
st.write("Disfluency Counts: ", disfluency_counts)
|
342 |
|
|
|
343 |
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
|
348 |
-
|
349 |
-
# ์ด์ ์ ๊ธฐ๋ก๋ ๊ฐ์ด ์๋ค๋ฉด, ๊ทธ๋ํ๋ฅผ ๊ทธ๋ฆฌ์ง ์์ต๋๋ค.
|
350 |
|
351 |
-
|
|
|
|
|
|
|
352 |
|
|
|
353 |
|
|
|
|
|
|
|
|
|
354 |
|
|
|
|
|
355 |
|
|
|
|
|
|
|
|
|
|
|
|
|
356 |
|
357 |
-
|
358 |
|
|
|
|
|
359 |
|
360 |
-
|
361 |
-
|
362 |
-
#########################################################
|
363 |
-
def page7():
|
364 |
-
st.header('Debate Judgement')
|
365 |
-
# ์ ์ ์ ๋ด์ ๋ํ ๋ฐ์ดํฐ๊ฐ ์ธ์
์ ๋จ์์์
|
366 |
-
# st.session_state.debate_history
|
367 |
|
368 |
-
|
|
|
369 |
|
370 |
-
|
371 |
-
judgement_who = st.selectbox("Choose your debate theme", debate_themes)
|
372 |
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
|
|
379 |
|
380 |
-
|
|
|
|
|
|
|
381 |
|
382 |
-
|
383 |
-
|
|
|
|
|
|
|
384 |
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
|
|
|
|
389 |
|
|
|
|
|
390 |
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
|
|
|
|
|
|
|
|
396 |
|
397 |
|
398 |
|
@@ -406,8 +426,6 @@ pages = {
|
|
406 |
"Page 4": page4, # Evaluation Only
|
407 |
"Page 5": page5, # Analyzing Utterances
|
408 |
"Page 6": page6,
|
409 |
-
"Page 7": page7,
|
410 |
-
"Page 8": page8
|
411 |
}
|
412 |
|
413 |
selection = st.session_state.page
|
|
|
85 |
def page_5_6_controller():
|
86 |
st.session_state.page = "Page 6"
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
#########################################################
|
89 |
# Page 1
|
90 |
#########################################################
|
|
|
269 |
# Page5 - Total Debate Evaluation
|
270 |
#########################################################
|
271 |
def page5():
|
|
|
|
|
|
|
272 |
|
273 |
+
# st.tab
|
274 |
+
st.header('Total Debate Evaluation')
|
275 |
|
276 |
+
tab1, tab2 = st.tabs(['Debate Judgement', 'Debate Analysis'])
|
|
|
277 |
|
278 |
+
with tab1:
|
279 |
+
st.header("Debate Evaluation")
|
280 |
+
|
281 |
+
debate_themes = ['User-Bot', "User", "Bot"]
|
|
|
|
|
282 |
|
283 |
+
# ์ ์ฒด, ์ ์ , ๋ด ์ธ ๊ฐ์ง ์ต์
์ค์ ์ ํ
|
284 |
+
judgement_who = st.selectbox("Choose your debate theme", debate_themes)
|
285 |
|
286 |
+
if judgement_who == 'User-Bot':
|
287 |
+
debate_history = st.session_state.total_debate_history
|
288 |
+
elif judgement_who == 'User':
|
289 |
+
debate_history = st.session_state.user_debate_history
|
290 |
+
elif judgement_who == 'Bot':
|
291 |
+
debate_history = st.session_state.bot_debate_history
|
292 |
|
293 |
+
judgement_result = debate_judgement(debate_history)
|
|
|
|
|
|
|
294 |
|
295 |
+
st.write("Debate Judgement Result")
|
296 |
+
st.write(judgement_result)
|
|
|
297 |
|
298 |
+
with tab2:
|
299 |
+
st.header('Debate Analysis')
|
300 |
|
301 |
+
# ์ ์ ์ history๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๋ฐํ๋, ๋น์ถ ๋จ์ด, ๋ฐํ ์ต๊ด ์ธ ๊ฐ์ง๋ฅผ ๋ถ์
|
302 |
+
user_history = st.session_state.user_debate_history
|
303 |
|
304 |
+
# 1. ๋ฐํ๋: ์ด ๋จ์ด, ํ๊ท ์๋(๋จ์ด/์๊ฐ)๋ฅผ ํ๊ท ๋ฐํ๋ ํน์ ์ฐธ๊ณ ์งํ์ ๋น๊ตํด ์ ์
|
|
|
305 |
|
306 |
+
# ์ด ๋จ์ด
|
307 |
+
# ํ
์คํธ๋ฅผ ๋จ์ด๋ก ๋ถํ ํฉ๋๋ค.
|
308 |
+
words = user_history.split()
|
309 |
+
# ๊ฐ ๋จ์ด์ ๋น๋๋ฅผ ๊ณ์ฐํฉ๋๋ค.
|
310 |
+
total_word_count = Counter(words)
|
311 |
+
#total_word_count = len(user_history.split())
|
312 |
+
st.write("Total Word Count: ", total_word_count)
|
313 |
|
314 |
+
# ํ๊ท ์๋(๋จ์ด/์๊ฐ)
|
315 |
+
user_debate_time = st.session_state.user_debate_time
|
316 |
+
average_word_per_time = total_word_count / user_debate_time # ์๊ฐ ๋จ์๋ณด๊ณ ๋์ค์ ์์ ํ๊ธฐ
|
317 |
+
st.write("Average Word Per Time: ", average_word_per_time)
|
|
|
|
|
|
|
318 |
|
319 |
+
# 2. ๋น์ถ ๋จ์ด: ๋ฐ๋ณตํด์ ์ฌ์ฉํ๋ ๋จ์ด ๋ฆฌ์คํธ
|
320 |
+
# ๋น๋๊ฐ ๋์ ์์๋๋ก ๋จ์ด๋ฅผ ์ ๋ ฌํฉ๋๋ค.
|
321 |
+
most_common_words = total_word_count.most_common()
|
322 |
+
# ๊ฐ์ฅ ๋น๋๊ฐ ๋์ 10๊ฐ์ ๋จ์ด๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
|
323 |
+
st.write("Most Common Words: ", most_common_words[:10])
|
324 |
|
325 |
+
# 3. ๋ฐํ ์ต๊ด: ๋ถํ์ํ ์ธ์ด์ต๊ด(์, ์)
|
326 |
+
# whisper preprocesser์์ ์ฃผ๋ฉด
|
327 |
+
disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
|
328 |
+
# Count the disfluency words
|
329 |
+
disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
|
330 |
+
st.write("Disfluency Counts: ", disfluency_counts)
|
331 |
|
332 |
+
# ์ ์ ์ ๋ด์ ๋ํ ๋ฐ์ดํฐ๊ฐ ์ธ์
์ ๋จ์์์
|
333 |
+
# st.session_state.debate_history
|
|
|
|
|
|
|
|
|
334 |
|
335 |
+
|
336 |
|
337 |
+
#########################################################
|
338 |
+
# Page6
|
339 |
+
#########################################################
|
340 |
|
341 |
+
def page6():
|
|
|
342 |
|
343 |
+
# ์ฌ๊ธฐ์ User์ ๊ณผ๊ฑฐ ๊ธฐ๋ก์ ๊ฒ์ํ ์ ์๊ฒ ํด์ผ ํจ
|
344 |
+
|
345 |
+
# st.tab
|
346 |
+
st.header('Total Debate Evaluation')
|
347 |
|
348 |
+
tab1, tab2 = st.tabs(['Debate Judgement', 'Debate Analysis'])
|
349 |
|
350 |
+
with tab1:
|
351 |
+
st.header("Debate Evaluation")
|
352 |
+
|
353 |
+
debate_themes = ['User-Bot', "User", "Bot"]
|
354 |
|
355 |
+
# ์ ์ฒด, ์ ์ , ๋ด ์ธ ๊ฐ์ง ์ต์
์ค์ ์ ํ
|
356 |
+
judgement_who = st.selectbox("Choose your debate theme", debate_themes)
|
357 |
|
358 |
+
if judgement_who == 'User-Bot':
|
359 |
+
debate_history = st.session_state.total_debate_history
|
360 |
+
elif judgement_who == 'User':
|
361 |
+
debate_history = st.session_state.user_debate_history
|
362 |
+
elif judgement_who == 'Bot':
|
363 |
+
debate_history = st.session_state.bot_debate_history
|
364 |
|
365 |
+
judgement_result = debate_judgement(debate_history)
|
366 |
|
367 |
+
st.write("Debate Judgement Result")
|
368 |
+
st.write(judgement_result)
|
369 |
|
370 |
+
with tab2:
|
371 |
+
st.header('Debate Analysis')
|
|
|
|
|
|
|
|
|
|
|
372 |
|
373 |
+
# ์ ์ ์ history๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๋ฐํ๋, ๋น์ถ ๋จ์ด, ๋ฐํ ์ต๊ด ์ธ ๊ฐ์ง๋ฅผ ๋ถ์
|
374 |
+
user_history = st.session_state.user_debate_history
|
375 |
|
376 |
+
# 1. ๋ฐํ๋: ์ด ๋จ์ด, ํ๊ท ์๋(๋จ์ด/์๊ฐ)๋ฅผ ํ๊ท ๋ฐํ๋ ํน์ ์ฐธ๊ณ ์งํ์ ๋น๊ตํด ์ ์
|
|
|
377 |
|
378 |
+
# ์ด ๋จ์ด
|
379 |
+
# ํ
์คํธ๋ฅผ ๋จ์ด๋ก ๋ถํ ํฉ๋๋ค.
|
380 |
+
words = user_history.split()
|
381 |
+
# ๊ฐ ๋จ์ด์ ๋น๋๋ฅผ ๊ณ์ฐํฉ๋๋ค.
|
382 |
+
total_word_count = Counter(words)
|
383 |
+
#total_word_count = len(user_history.split())
|
384 |
+
st.write("Total Word Count: ", total_word_count)
|
385 |
|
386 |
+
# ํ๊ท ์๋(๋จ์ด/์๊ฐ)
|
387 |
+
user_debate_time = st.session_state.user_debate_time
|
388 |
+
average_word_per_time = total_word_count / user_debate_time # ์๊ฐ ๋จ์๋ณด๊ณ ๋์ค์ ์์ ํ๊ธฐ
|
389 |
+
st.write("Average Word Per Time: ", average_word_per_time)
|
390 |
|
391 |
+
# 2. ๋น์ถ ๋จ์ด: ๋ฐ๋ณตํด์ ์ฌ์ฉํ๋ ๋จ์ด ๋ฆฌ์คํธ
|
392 |
+
# ๋น๋๊ฐ ๋์ ์์๋๋ก ๋จ์ด๋ฅผ ์ ๋ ฌํฉ๋๋ค.
|
393 |
+
most_common_words = total_word_count.most_common()
|
394 |
+
# ๊ฐ์ฅ ๋น๋๊ฐ ๋์ 10๊ฐ์ ๋จ์ด๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
|
395 |
+
st.write("Most Common Words: ", most_common_words[:10])
|
396 |
|
397 |
+
# 3. ๋ฐํ ์ต๊ด: ๋ถํ์ํ ์ธ์ด์ต๊ด(์, ์)
|
398 |
+
# whisper preprocesser์์ ์ฃผ๋ฉด
|
399 |
+
disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
|
400 |
+
# Count the disfluency words
|
401 |
+
disfluency_counts = {word: total_word_count[word] for word in disfluency_word_list}
|
402 |
+
st.write("Disfluency Counts: ", disfluency_counts)
|
403 |
|
404 |
+
# ์ ์ ์ ๋ด์ ๋ํ ๋ฐ์ดํฐ๊ฐ ์ธ์
์ ๋จ์์์
|
405 |
+
# st.session_state.debate_history
|
406 |
|
407 |
+
|
408 |
+
|
409 |
+
|
410 |
+
############################################
|
411 |
+
# Visualization
|
412 |
+
############################################
|
413 |
+
|
414 |
+
# ์ด์ ์ ๊ธฐ๋ก๋ ๊ฐ์ด ์๋ค๋ฉด, ๏ฟฝ๏ฟฝ๋ํ๋ฅผ ๊ทธ๋ฆฝ๋๋ค.
|
415 |
+
# ์ด์ ์ ๊ธฐ๋ก๋ ๊ฐ์ด ์๋ค๋ฉด, ๊ทธ๋ํ๋ฅผ ๊ทธ๋ฆฌ์ง ์์ต๋๋ค.
|
416 |
|
417 |
|
418 |
|
|
|
426 |
"Page 4": page4, # Evaluation Only
|
427 |
"Page 5": page5, # Analyzing Utterances
|
428 |
"Page 6": page6,
|
|
|
|
|
429 |
}
|
430 |
|
431 |
selection = st.session_state.page
|