codingchild commited on
Commit
6140dc1
โ€ข
1 Parent(s): 8ae9a20

change page

Browse files
Files changed (1) hide show
  1. 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
- debate_themes = ['User-Bot', "User", "Bot"]
 
283
 
284
- # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
285
- judgement_who = st.selectbox("Choose your debate theme", debate_themes)
286
 
287
- if judgement_who == 'User-Bot':
288
- debate_history = st.session_state.total_debate_history
289
- elif judgement_who == 'User':
290
- debate_history = st.session_state.user_debate_history
291
- elif judgement_who == 'Bot':
292
- debate_history = st.session_state.bot_debate_history
293
 
294
- judgement_result = debate_judgement(debate_history)
 
295
 
296
- st.write("Debate Judgement Result")
297
- st.write(judgement_result)
 
 
 
 
298
 
299
- st.button(
300
- label='Move to Debate Dashboard',
301
- on_click=page_5_6_controller
302
- )
303
 
304
- #########################################################
305
- # Page6
306
- #########################################################
307
 
308
- def page6():
 
309
 
310
- st.header('Debate Analysis')
 
311
 
312
- # ์œ ์ €์˜ history๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฐœํ™”๋Ÿ‰, ๋นˆ์ถœ ๋‹จ์–ด, ๋ฐœํ™” ์Šต๊ด€ ์„ธ ๊ฐ€์ง€๋ฅผ ๋ถ„์„
313
- user_history = st.session_state.user_debate_history
314
 
315
- # 1. ๋ฐœํ™”๋Ÿ‰: ์ด ๋‹จ์–ด, ํ‰๊ท  ์†๋„(๋‹จ์–ด/์‹œ๊ฐ„)๋ฅผ ํ‰๊ท  ๋ฐœํ™”๋Ÿ‰ ํ˜น์€ ์ฐธ๊ณ  ์ง€ํ‘œ์™€ ๋น„๊ตํ•ด ์ œ์‹œ
 
 
 
 
 
 
316
 
317
- # ์ด ๋‹จ์–ด
318
- # ํ…์ŠคํŠธ๋ฅผ ๋‹จ์–ด๋กœ ๋ถ„ํ• ํ•ฉ๋‹ˆ๋‹ค.
319
- words = user_history.split()
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
- user_debate_time = st.session_state.user_debate_time
327
- average_word_per_time = total_word_count / user_debate_time # ์‹œ๊ฐ„ ๋‹จ์œ„๋ณด๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๊ธฐ
328
- st.write("Average Word Per Time: ", average_word_per_time)
 
329
 
330
- # 2. ๋นˆ์ถœ ๋‹จ์–ด: ๋ฐ˜๋ณตํ•ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๋‹จ์–ด ๋ฆฌ์ŠคํŠธ
331
- # ๋นˆ๋„๊ฐ€ ๋†’์€ ์ˆœ์„œ๋Œ€๋กœ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค.
332
- most_common_words = total_word_count.most_common()
333
- # ๊ฐ€์žฅ ๋นˆ๋„๊ฐ€ ๋†’์€ 10๊ฐœ์˜ ๋‹จ์–ด๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
334
- st.write("Most Common Words: ", most_common_words[:10])
 
335
 
336
- # 3. ๋ฐœํ™” ์Šต๊ด€: ๋ถˆํ•„์š”ํ•œ ์–ธ์–ด์Šต๊ด€(์•„, ์Œ)
337
- # whisper preprocesser์—์„œ ์ฃผ๋ฉด
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
- # Visualization
346
- ############################################
347
 
348
- # ์ด์ „์— ๊ธฐ๋ก๋œ ๊ฐ’์ด ์žˆ๋‹ค๋ฉด, ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฝ๋‹ˆ๋‹ค.
349
- # ์ด์ „์— ๊ธฐ๋ก๋œ ๊ฐ’์ด ์—†๋‹ค๋ฉด, ๊ทธ๋ž˜ํ”„๋ฅผ ๊ทธ๋ฆฌ์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
350
 
351
-
 
 
 
352
 
 
353
 
 
 
 
 
354
 
 
 
355
 
 
 
 
 
 
 
356
 
357
- pass
358
 
 
 
359
 
360
- #########################################################
361
- # Page7
362
- #########################################################
363
- def page7():
364
- st.header('Debate Judgement')
365
- # ์œ ์ €์™€ ๋ด‡์˜ ๋Œ€ํ™” ๋ฐ์ดํ„ฐ๊ฐ€ ์„ธ์…˜์— ๋‚จ์•„์žˆ์Œ
366
- # st.session_state.debate_history
367
 
368
- debate_themes = ['User-Bot', "User", "Bot"]
 
369
 
370
- # ์ „์ฒด, ์œ ์ €, ๋ด‡ ์„ธ ๊ฐ€์ง€ ์˜ต์…˜ ์ค‘์— ์„ ํƒ
371
- judgement_who = st.selectbox("Choose your debate theme", debate_themes)
372
 
373
- if judgement_who == 'User-Bot':
374
- debate_history = st.session_state.total_debate_history
375
- elif judgement_who == 'User':
376
- debate_history = st.session_state.user_debate_history
377
- elif judgement_who == 'Bot':
378
- debate_history = st.session_state.bot_debate_history
 
379
 
380
- judgement_result = debate_judgement(debate_history)
 
 
 
381
 
382
- st.write("Debate Judgement Result")
383
- st.write(judgement_result)
 
 
 
384
 
385
- st.button(
386
- label='Move to Debate Dashboard',
387
- on_click=page_5_6_controller
388
- )
 
 
389
 
 
 
390
 
391
- #########################################################
392
- # Page8
393
- #########################################################
394
- def page8():
395
- pass
 
 
 
 
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