Spaces:
Runtime error
Runtime error
refactor: disconnect DB module
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ from audiorecorder import audiorecorder
|
|
12 |
|
13 |
# internal modules
|
14 |
from bots.judgement_bot import debate_judgement
|
15 |
-
from modules.db_modules import get_db, put_item,
|
16 |
from modules.gpt_modules import gpt_call, gpt_call_context
|
17 |
from modules.whisper_modules import whisper_transcribe
|
18 |
from modules.setting_modules import blockPrint
|
@@ -30,7 +30,7 @@ st.set_page_config(page_title="Debate With GPT : DEBO")
|
|
30 |
#########################################################
|
31 |
# GET DB
|
32 |
#########################################################
|
33 |
-
dynamodb = get_db()
|
34 |
|
35 |
#########################################################
|
36 |
# Time Stamp
|
@@ -112,18 +112,12 @@ def page_1_2_controller():
|
|
112 |
def page_2_4_controller():
|
113 |
st.session_state.page = "Page 4"
|
114 |
|
115 |
-
# def page_3_4_controller():
|
116 |
-
# st.session_state.page = "Page 4"
|
117 |
-
|
118 |
def page_4_5_controller():
|
119 |
st.session_state.page = "Page 5"
|
120 |
|
121 |
def page_5_6_controller():
|
122 |
st.session_state.page = "Page 6"
|
123 |
|
124 |
-
# def page_2_7_controller():
|
125 |
-
# st.session_state.page = "Page 7"
|
126 |
-
|
127 |
def page_n_1_controller():
|
128 |
st.session_state.page = "Page 1"
|
129 |
|
@@ -161,18 +155,18 @@ def save_info(user_id):
|
|
161 |
#########################################################
|
162 |
# Session Update
|
163 |
#########################################################
|
164 |
-
debate_setting = get_lastest_item(
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
)
|
170 |
-
#
|
171 |
-
|
172 |
-
|
173 |
-
#
|
174 |
-
|
175 |
-
|
176 |
|
177 |
def page1():
|
178 |
val_id = False
|
@@ -260,51 +254,6 @@ def page2():
|
|
260 |
on_click=page_control_func,
|
261 |
)
|
262 |
|
263 |
-
#########################################################
|
264 |
-
# Page 3
|
265 |
-
#########################################################
|
266 |
-
# def page3():
|
267 |
-
# debate_history = get_lastest_item(
|
268 |
-
# table=dynamodb.Table('DEBO_debate_setting'),
|
269 |
-
# name_of_partition_key="user_id",
|
270 |
-
# value_of_partition_key=st.session_state.user_id,
|
271 |
-
# #TODO 전체 보여줄 개수 설정
|
272 |
-
# limit_num=10
|
273 |
-
# )
|
274 |
-
|
275 |
-
# if not debate_history:
|
276 |
-
# st.info('There is no previous debate history', icon="ℹ️")
|
277 |
-
|
278 |
-
# _, _, pre, home = st.columns([5, 5, 1, 1])
|
279 |
-
# with pre:
|
280 |
-
# st.button("🔙", on_click=page_1_2_controller, use_container_width=True)
|
281 |
-
# with home:
|
282 |
-
# st.button("🔝", on_click=page_n_1_controller, use_container_width=True)
|
283 |
-
# st.header("Debate History")
|
284 |
-
|
285 |
-
# st.button(
|
286 |
-
# label=f'🚀 Start new debate',
|
287 |
-
# type='primary',
|
288 |
-
# on_click=page_3_4_controller
|
289 |
-
# )
|
290 |
-
# st.write("_"*50)
|
291 |
-
|
292 |
-
# num_history = len(debate_history)
|
293 |
-
# for i in range(num_history):
|
294 |
-
# with st.container():
|
295 |
-
# st.write(f"#### {i + 1}")
|
296 |
-
# st.write(f"Debate Thema : {debate_history[i]['debate_theme']}")
|
297 |
-
# st.write(f"Debate Topic : {debate_history[i]['debate_topic']}")
|
298 |
-
# st.write(f"Case 1 : {debate_history[i]['case1']}")
|
299 |
-
# st.write(f"Case 2 : {debate_history[i]['case2']}")
|
300 |
-
# st.write(f"Case 3 : {debate_history[i]['case3']}")
|
301 |
-
# st.write(f"Created at : {debate_history[i]['time_stamp']}")
|
302 |
-
# st.button(
|
303 |
-
# label='Continue this dabate',
|
304 |
-
# key=str(i),
|
305 |
-
# on_click=page_4_5_controller
|
306 |
-
# )
|
307 |
-
# st.write("_"*50)
|
308 |
|
309 |
#########################################################
|
310 |
# Page 4
|
@@ -315,19 +264,19 @@ def store_debate_data(checked, case1, case2, case3):
|
|
315 |
if not checked:
|
316 |
st.session_state.case1, st.session_state.case2, st.session_state.case3 = case1, case2, case3
|
317 |
|
318 |
-
put_item(
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
)
|
331 |
|
332 |
def page4():
|
333 |
#########################################################
|
@@ -423,7 +372,7 @@ def page4():
|
|
423 |
key="disabled",
|
424 |
)
|
425 |
#########################################################
|
426 |
-
#
|
427 |
#########################################################
|
428 |
case1 = st.text_area(
|
429 |
label="Write a Case 1",
|
@@ -498,17 +447,17 @@ def page4():
|
|
498 |
st.experimental_rerun()
|
499 |
st.stop()
|
500 |
|
501 |
-
#
|
502 |
-
put_item(
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
)
|
512 |
|
513 |
else:
|
514 |
result = st.session_state.ask_gpt_prev_response
|
@@ -585,16 +534,16 @@ def page5():
|
|
585 |
st.experimental_rerun()
|
586 |
st.stop()
|
587 |
|
588 |
-
put_item(
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
)
|
598 |
else:
|
599 |
result = st.session_state.ask_gpt_prev_response
|
600 |
|
@@ -693,28 +642,28 @@ def page5():
|
|
693 |
st.stop()
|
694 |
st.session_state['pre_audio'] = audio
|
695 |
|
696 |
-
debate_main_latest_data = get_lastest_item(
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
)
|
702 |
-
if not debate_main_latest_data:
|
703 |
-
|
704 |
-
else:
|
705 |
-
|
706 |
-
|
707 |
-
put_item(
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
)
|
718 |
else:
|
719 |
send_error_message.error("Please record your voice first", icon="🚨")
|
720 |
reload = True
|
@@ -739,7 +688,6 @@ def page5():
|
|
739 |
audio_bytes = audio_file.read()
|
740 |
st.audio(audio_bytes, format='audio/ogg')
|
741 |
|
742 |
-
#TODO zip_longest() 고려하기!
|
743 |
message_pairs = zip(
|
744 |
st.session_state['bot_debate_history'][1:],
|
745 |
st.session_state['user_debate_history'],
|
@@ -747,8 +695,7 @@ def page5():
|
|
747 |
for i, (bot_hist, user_hist) in enumerate(message_pairs):
|
748 |
message(user_hist, is_user=True, key=str(i)+'_user')
|
749 |
message(bot_hist, key=str(i + 1)+'_bot')
|
750 |
-
|
751 |
-
#TODO 생성된 message와 음성 파일 path를 하나의 객체로 관리하는 방법 고민
|
752 |
if i == len(st.session_state['bot_debate_history']) - 2 and not reload:
|
753 |
text_to_speech = gTTS(text=bot_hist, lang='en', slow=False)
|
754 |
text_to_speech.save(f"audio/ses_{st.session_state['session_num']}_bot_res_{str(i + 1)}.mp3")
|
@@ -808,9 +755,6 @@ def page6():
|
|
808 |
with tab1:
|
809 |
st.header("Debate Evaluation")
|
810 |
|
811 |
-
# 전체, 유저, 봇 세 가지 옵션 중에 선택
|
812 |
-
#judgement_who = st.selectbox("Choose what you want! (Evaluation result / Perfect case on this theme)", debate_themes)
|
813 |
-
|
814 |
if st.session_state.judgement_result == "":
|
815 |
with st.spinner('Wait for result...'):
|
816 |
judgement_result = ""
|
@@ -830,40 +774,20 @@ def page6():
|
|
830 |
st.write("Debate Judgement Result")
|
831 |
st.write(judgement_result)
|
832 |
|
833 |
-
if judgement_result != "":
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
st.success('Done!')
|
844 |
else:
|
845 |
st.write(st.session_state.judgement_result)
|
846 |
|
847 |
-
# with tab2:
|
848 |
-
# st.header("Perfect Case")
|
849 |
-
|
850 |
-
# perfect_case_list = [
|
851 |
-
# "This house supports the creation of an international court with a mandate to prosecute leaders for health crimes",
|
852 |
-
# "This house believes that governments would be justified in heavily pursuing long-termism",
|
853 |
-
# "THBT international discussion forums should not self-censor* in an attempt to increase inclusivity to people from countries with stringent freedom-of-speech rules.",
|
854 |
-
# ]
|
855 |
-
|
856 |
-
# perfect_case_selected = st.selectbox("Choose the Perfect Case", perfect_case_list)
|
857 |
-
|
858 |
-
# perfect_case = perfect_case_selector(
|
859 |
-
# perfect_case_selected
|
860 |
-
# )
|
861 |
-
|
862 |
-
# perfect_case_url = perfect_case['perfect_case_url']
|
863 |
-
# perfect_case_text = perfect_case['perfect_case_text']
|
864 |
-
|
865 |
-
# st.video(perfect_case_url)
|
866 |
-
# st.write(perfect_case_text)
|
867 |
|
868 |
with tab2:
|
869 |
st.header('Debate Analysis')
|
@@ -910,153 +834,19 @@ def page6():
|
|
910 |
disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
|
911 |
st.write("Disfluency Counts: ", disfluency_counts)
|
912 |
|
913 |
-
if total_word_count != "" and average_word_per_time != "" and disfluency_counts != "":
|
914 |
-
|
915 |
-
put_item(
|
916 |
-
table=dynamodb.Table('DEBO_debate_analysis'),
|
917 |
-
item={
|
918 |
-
'user_id': st.session_state.user_id,
|
919 |
-
'time_stamp': time_stamp,
|
920 |
-
'total_word_count': total_word_count,
|
921 |
-
'average_word_per_time': Decimal(str(average_word_per_time)),
|
922 |
-
'disfluency_counts': disfluency_counts,
|
923 |
-
'session_num': int(st.session_state.session_num),
|
924 |
-
}
|
925 |
-
)
|
926 |
-
|
927 |
-
# 유저와 봇의 대화 데이터가 세션에 남아있음
|
928 |
-
# st.session_state.debate_history
|
929 |
-
|
930 |
-
############################################
|
931 |
-
# Visualization
|
932 |
-
############################################
|
933 |
-
|
934 |
-
# 이전에 기록된 값이 있다면, 그래프를 그립니다.
|
935 |
-
# ���전에 기록된 값이 없다면, 그래프를 그리지 않습니다.
|
936 |
-
|
937 |
-
|
938 |
-
#########################################################
|
939 |
-
# Page7
|
940 |
-
#########################################################
|
941 |
-
|
942 |
-
# def page7():
|
943 |
-
|
944 |
-
# # end time
|
945 |
-
# st.session_state.end_time = time.time()
|
946 |
-
# st.session_state.debate_time = st.session_state.end_time - st.session_state.start_time
|
947 |
-
|
948 |
-
# _, _, pre, home = st.columns([5, 5, 1, 1])
|
949 |
-
# with pre:
|
950 |
-
# st.button("🔙", on_click=page_1_2_controller, use_container_width=True)
|
951 |
-
# with home:
|
952 |
-
# st.button("🔝", on_click=page_n_1_controller, use_container_width=True)
|
953 |
-
|
954 |
-
# st.header('Total Debate Evaluation')
|
955 |
|
956 |
-
#
|
957 |
-
|
958 |
-
#
|
959 |
-
#
|
960 |
-
|
961 |
-
#
|
962 |
-
|
963 |
-
#
|
964 |
-
#
|
965 |
-
|
966 |
-
#
|
967 |
-
# with st.spinner('Wait for judgement result...'):
|
968 |
-
# judgement_result = ""
|
969 |
-
|
970 |
-
# user_debate_history = "".join(
|
971 |
-
# st.session_state.user_debate_history
|
972 |
-
# )
|
973 |
-
# bot_debate_history = "".join(
|
974 |
-
# st.session_state.bot_debate_history
|
975 |
-
# )
|
976 |
-
|
977 |
-
# judgement_result = debate_judgement(
|
978 |
-
# judgement_who,
|
979 |
-
# user_debate_history,
|
980 |
-
# bot_debate_history
|
981 |
-
# )
|
982 |
-
|
983 |
-
# st.session_state.judgement_result = judgement_result
|
984 |
-
|
985 |
-
# st.write("Debate Judgement Result")
|
986 |
-
# st.write(judgement_result)
|
987 |
-
|
988 |
-
# if judgement_result:
|
989 |
-
# put_item(
|
990 |
-
# table=dynamodb.Table('DEBO_evaluation'),
|
991 |
-
# item={
|
992 |
-
# 'user_id': st.session_state.user_id,
|
993 |
-
# 'time_stamp': time_stamp,
|
994 |
-
# 'judgement_text': judgement_result,
|
995 |
-
# 'session_num': int(st.session_state.session_num),
|
996 |
-
# }
|
997 |
-
# )
|
998 |
-
# st.success('Done!')
|
999 |
-
# else:
|
1000 |
-
# st.write(st.session_state.judgement_result)
|
1001 |
-
|
1002 |
-
# with tab2:
|
1003 |
-
# st.header('Debate Analysis')
|
1004 |
-
|
1005 |
-
# # 유저의 history를 기반으로 발화량, 빈출 단어, 발화 습관 세 가지를 분석
|
1006 |
-
# user_history = st.session_state.user_debate_history
|
1007 |
-
|
1008 |
-
# # 1. 발화량: 총 단어, 평균 속도(단어/시간)를 평균 발화량 혹은 참고 지표와 비교해 제시
|
1009 |
-
|
1010 |
-
# # 총 단어
|
1011 |
-
# # 텍스트를 단어로 분할합니다.
|
1012 |
-
# # 각 단어의 빈도를 계산합니다.
|
1013 |
-
# total_word_count = len(user_history)
|
1014 |
-
# #total_word_count = len(user_history.split())
|
1015 |
-
# st.write("Total Word Count: ", total_word_count)
|
1016 |
-
|
1017 |
-
# # 평균 속도(단어/시간)
|
1018 |
-
# #user_debate_time = st.session_state.user_debate_time
|
1019 |
-
# average_word_per_time = total_word_count / st.session_state.debate_time # 시간 단위보고 나중에 수정하기
|
1020 |
-
# st.write("Average Word Per Time: ", average_word_per_time)
|
1021 |
-
|
1022 |
-
# # 2. 빈출 단어: 반복해서 사용하는 단어 리스트
|
1023 |
-
# # 빈도 계산
|
1024 |
-
# frequency = Counter(user_history)
|
1025 |
-
# # 가장 빈도가 높은 데이터 출력
|
1026 |
-
# most_common_data = frequency.most_common(10)
|
1027 |
-
#
|
1028 |
-
# print(most_common_data)
|
1029 |
-
# st.write("Most Common Words: ", most_common_data)
|
1030 |
-
|
1031 |
-
# # 3. 발화 습관: 불필요한 언어습관(아, 음)
|
1032 |
-
# # whisper preprocesser에서 주면
|
1033 |
-
# disfluency_word_list = ['eh', 'umm', 'ah', 'uh', 'er', 'erm', 'err']
|
1034 |
-
# # Count the disfluency words
|
1035 |
-
# disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
|
1036 |
-
# st.write("Disfluency Counts: ", disfluency_counts)
|
1037 |
-
|
1038 |
-
# if total_word_count != "" and average_word_per_time != "" and disfluency_counts != "":
|
1039 |
-
# put_item(
|
1040 |
-
# table=dynamodb.Table('DEBO_evaluation'),
|
1041 |
-
# item={
|
1042 |
-
# 'user_id': st.session_state.user_id,
|
1043 |
-
# 'time_stamp': time_stamp,
|
1044 |
-
# 'total_word_count': total_word_count,
|
1045 |
-
# 'average_word_per_time': Decimal(str(average_word_per_time)),
|
1046 |
-
# 'disfluency_counts': disfluency_counts,
|
1047 |
-
# 'session_num': int(st.session_state.session_num),
|
1048 |
-
# }
|
1049 |
-
# )
|
1050 |
-
|
1051 |
-
# 유저와 봇의 대화 데이터가 세션에 남아있음
|
1052 |
-
# st.session_state.debate_history
|
1053 |
-
|
1054 |
-
############################################
|
1055 |
-
# Visualization
|
1056 |
-
############################################
|
1057 |
-
|
1058 |
-
# 이전에 기록된 값이 있다면, 그래프를 그립니다.
|
1059 |
-
# 이전에 기록된 값이 없다면, 그래프를 그리지 않습니다.
|
1060 |
|
1061 |
|
1062 |
#########################################################
|
@@ -1065,11 +855,9 @@ def page6():
|
|
1065 |
pages = {
|
1066 |
"Page 1": page1, # user_id를 입력받는 페이지
|
1067 |
"Page 2": page2, # 원하는 기능을 선택하는 페이지
|
1068 |
-
# "Page 3": page3, # 과거 토론 내역을 선택하는 페이지
|
1069 |
"Page 4": page4, # 토론 세부사항 설정
|
1070 |
"Page 5": page5, # Total Debate
|
1071 |
"Page 6": page6, # Evaluation Only
|
1072 |
-
# "Page 7": page7, # Analyzing Utterances
|
1073 |
}
|
1074 |
|
1075 |
selection = st.session_state.page
|
|
|
12 |
|
13 |
# internal modules
|
14 |
from bots.judgement_bot import debate_judgement
|
15 |
+
# from modules.db_modules import get_db, put_item, get_lastest_item
|
16 |
from modules.gpt_modules import gpt_call, gpt_call_context
|
17 |
from modules.whisper_modules import whisper_transcribe
|
18 |
from modules.setting_modules import blockPrint
|
|
|
30 |
#########################################################
|
31 |
# GET DB
|
32 |
#########################################################
|
33 |
+
# dynamodb = get_db()
|
34 |
|
35 |
#########################################################
|
36 |
# Time Stamp
|
|
|
112 |
def page_2_4_controller():
|
113 |
st.session_state.page = "Page 4"
|
114 |
|
|
|
|
|
|
|
115 |
def page_4_5_controller():
|
116 |
st.session_state.page = "Page 5"
|
117 |
|
118 |
def page_5_6_controller():
|
119 |
st.session_state.page = "Page 6"
|
120 |
|
|
|
|
|
|
|
121 |
def page_n_1_controller():
|
122 |
st.session_state.page = "Page 1"
|
123 |
|
|
|
155 |
#########################################################
|
156 |
# Session Update
|
157 |
#########################################################
|
158 |
+
# debate_setting = get_lastest_item(
|
159 |
+
# table=dynamodb.Table('DEBO_debate_setting'),
|
160 |
+
# name_of_partition_key="user_id",
|
161 |
+
# value_of_partition_key=st.session_state.user_id,
|
162 |
+
# limit_num=1
|
163 |
+
# )
|
164 |
+
# if not debate_setting:
|
165 |
+
# st.session_state.session_num = 0
|
166 |
+
# else:
|
167 |
+
# st.session_state.session_num = debate_setting[0]['session_num']
|
168 |
+
st.session_state.session_num = 0
|
169 |
+
|
170 |
|
171 |
def page1():
|
172 |
val_id = False
|
|
|
254 |
on_click=page_control_func,
|
255 |
)
|
256 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
|
258 |
#########################################################
|
259 |
# Page 4
|
|
|
264 |
if not checked:
|
265 |
st.session_state.case1, st.session_state.case2, st.session_state.case3 = case1, case2, case3
|
266 |
|
267 |
+
# put_item(
|
268 |
+
# table=dynamodb.Table('DEBO_debate_setting'),
|
269 |
+
# item={
|
270 |
+
# 'user_id': st.session_state.user_id,
|
271 |
+
# 'time_stamp': time_stamp,
|
272 |
+
# 'debate_theme': st.session_state.debate_theme,
|
273 |
+
# 'debate_topic': st.session_state.topic,
|
274 |
+
# 'case1': st.session_state.case1,
|
275 |
+
# 'case2': st.session_state.case2,
|
276 |
+
# 'case3': st.session_state.case3,
|
277 |
+
# 'session_num': st.session_state.session_num,
|
278 |
+
# }
|
279 |
+
# )
|
280 |
|
281 |
def page4():
|
282 |
#########################################################
|
|
|
372 |
key="disabled",
|
373 |
)
|
374 |
#########################################################
|
375 |
+
# Save case in session
|
376 |
#########################################################
|
377 |
case1 = st.text_area(
|
378 |
label="Write a Case 1",
|
|
|
447 |
st.experimental_rerun()
|
448 |
st.stop()
|
449 |
|
450 |
+
# Save user_prompt and bot_response to database
|
451 |
+
# put_item(
|
452 |
+
# table=dynamodb.Table('DEBO_gpt_ask'),
|
453 |
+
# item={
|
454 |
+
# 'user_id': st.session_state.user_id,
|
455 |
+
# 'time_stamp': time_stamp,
|
456 |
+
# 'user_prompt': user_input,
|
457 |
+
# 'bot_response': result,
|
458 |
+
# 'session_num': st.session_state.session_num,
|
459 |
+
# }
|
460 |
+
# )
|
461 |
|
462 |
else:
|
463 |
result = st.session_state.ask_gpt_prev_response
|
|
|
534 |
st.experimental_rerun()
|
535 |
st.stop()
|
536 |
|
537 |
+
# put_item(
|
538 |
+
# table=dynamodb.Table('DEBO_gpt_ask'),
|
539 |
+
# item={
|
540 |
+
# 'user_id': st.session_state.user_id,
|
541 |
+
# 'time_stamp': time_stamp,
|
542 |
+
# 'user_prompt': user_input,
|
543 |
+
# 'bot_response': result,
|
544 |
+
# 'session_num': st.session_state.session_num,
|
545 |
+
# }
|
546 |
+
# )
|
547 |
else:
|
548 |
result = st.session_state.ask_gpt_prev_response
|
549 |
|
|
|
642 |
st.stop()
|
643 |
st.session_state['pre_audio'] = audio
|
644 |
|
645 |
+
# debate_main_latest_data = get_lastest_item(
|
646 |
+
# table=dynamodb.Table('DEBO_debate_main'),
|
647 |
+
# name_of_partition_key="user_id",
|
648 |
+
# value_of_partition_key=st.session_state.user_id,
|
649 |
+
# limit_num=1
|
650 |
+
# )
|
651 |
+
# if not debate_main_latest_data:
|
652 |
+
# turn_num = 0
|
653 |
+
# else:
|
654 |
+
# turn_num = debate_main_latest_data[0]['turn_num']
|
655 |
+
|
656 |
+
# put_item(
|
657 |
+
# table=dynamodb.Table('DEBO_debate_main'),
|
658 |
+
# item={
|
659 |
+
# 'user_id': st.session_state.user_id,
|
660 |
+
# 'time_stamp': time_stamp,
|
661 |
+
# 'session_num': st.session_state.session_num,
|
662 |
+
# 'bot_response': response,
|
663 |
+
# 'user_prompt': user_input,
|
664 |
+
# 'turn_num': turn_num,
|
665 |
+
# }
|
666 |
+
# )
|
667 |
else:
|
668 |
send_error_message.error("Please record your voice first", icon="🚨")
|
669 |
reload = True
|
|
|
688 |
audio_bytes = audio_file.read()
|
689 |
st.audio(audio_bytes, format='audio/ogg')
|
690 |
|
|
|
691 |
message_pairs = zip(
|
692 |
st.session_state['bot_debate_history'][1:],
|
693 |
st.session_state['user_debate_history'],
|
|
|
695 |
for i, (bot_hist, user_hist) in enumerate(message_pairs):
|
696 |
message(user_hist, is_user=True, key=str(i)+'_user')
|
697 |
message(bot_hist, key=str(i + 1)+'_bot')
|
698 |
+
|
|
|
699 |
if i == len(st.session_state['bot_debate_history']) - 2 and not reload:
|
700 |
text_to_speech = gTTS(text=bot_hist, lang='en', slow=False)
|
701 |
text_to_speech.save(f"audio/ses_{st.session_state['session_num']}_bot_res_{str(i + 1)}.mp3")
|
|
|
755 |
with tab1:
|
756 |
st.header("Debate Evaluation")
|
757 |
|
|
|
|
|
|
|
758 |
if st.session_state.judgement_result == "":
|
759 |
with st.spinner('Wait for result...'):
|
760 |
judgement_result = ""
|
|
|
774 |
st.write("Debate Judgement Result")
|
775 |
st.write(judgement_result)
|
776 |
|
777 |
+
# if judgement_result != "":
|
778 |
+
# put_item(
|
779 |
+
# table=dynamodb.Table('DEBO_evaluation'),
|
780 |
+
# item={
|
781 |
+
# 'user_id': st.session_state.user_id,
|
782 |
+
# 'time_stamp': time_stamp,
|
783 |
+
# 'judgement_text': judgement_result,
|
784 |
+
# 'session_num': st.session_state.session_num,
|
785 |
+
# }
|
786 |
+
# )
|
787 |
st.success('Done!')
|
788 |
else:
|
789 |
st.write(st.session_state.judgement_result)
|
790 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
791 |
|
792 |
with tab2:
|
793 |
st.header('Debate Analysis')
|
|
|
834 |
disfluency_counts = sum(user_word in disfluency_word_list for user_word in user_history)
|
835 |
st.write("Disfluency Counts: ", disfluency_counts)
|
836 |
|
837 |
+
# if total_word_count != "" and average_word_per_time != "" and disfluency_counts != "":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
838 |
|
839 |
+
# put_item(
|
840 |
+
# table=dynamodb.Table('DEBO_debate_analysis'),
|
841 |
+
# item={
|
842 |
+
# 'user_id': st.session_state.user_id,
|
843 |
+
# 'time_stamp': time_stamp,
|
844 |
+
# 'total_word_count': total_word_count,
|
845 |
+
# 'average_word_per_time': Decimal(str(average_word_per_time)),
|
846 |
+
# 'disfluency_counts': disfluency_counts,
|
847 |
+
# 'session_num': int(st.session_state.session_num),
|
848 |
+
# }
|
849 |
+
# )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
850 |
|
851 |
|
852 |
#########################################################
|
|
|
855 |
pages = {
|
856 |
"Page 1": page1, # user_id를 입력받는 페이지
|
857 |
"Page 2": page2, # 원하는 기능을 선택하는 페이지
|
|
|
858 |
"Page 4": page4, # 토론 세부사항 설정
|
859 |
"Page 5": page5, # Total Debate
|
860 |
"Page 6": page6, # Evaluation Only
|
|
|
861 |
}
|
862 |
|
863 |
selection = st.session_state.page
|