diff --git a/backend/__pycache__/__init__.cpython-311.pyc b/backend/__pycache__/__init__.cpython-311.pyc index bcea4d0..96fcb06 100644 Binary files a/backend/__pycache__/__init__.cpython-311.pyc and b/backend/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/app/__pycache__/__init__.cpython-311.pyc b/backend/app/__pycache__/__init__.cpython-311.pyc index ab3deb9..eecf6ea 100644 Binary files a/backend/app/__pycache__/__init__.cpython-311.pyc and b/backend/app/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/app/__pycache__/audio_util.cpython-39.pyc b/backend/app/__pycache__/audio_util.cpython-39.pyc new file mode 100644 index 0000000..74e4f55 Binary files /dev/null and b/backend/app/__pycache__/audio_util.cpython-39.pyc differ diff --git a/backend/app/__pycache__/func.cpython-311.pyc b/backend/app/__pycache__/func.cpython-311.pyc index b33ec45..d835724 100644 Binary files a/backend/app/__pycache__/func.cpython-311.pyc and b/backend/app/__pycache__/func.cpython-311.pyc differ diff --git a/backend/app/__pycache__/func.cpython-39.pyc b/backend/app/__pycache__/func.cpython-39.pyc new file mode 100644 index 0000000..9f34ac6 Binary files /dev/null and b/backend/app/__pycache__/func.cpython-39.pyc differ diff --git a/backend/app/__pycache__/main.cpython-311.pyc b/backend/app/__pycache__/main.cpython-311.pyc index 9d4dbd8..3006c5d 100644 Binary files a/backend/app/__pycache__/main.cpython-311.pyc and b/backend/app/__pycache__/main.cpython-311.pyc differ diff --git a/backend/app/__pycache__/main.cpython-39.pyc b/backend/app/__pycache__/main.cpython-39.pyc new file mode 100644 index 0000000..e862eb2 Binary files /dev/null and b/backend/app/__pycache__/main.cpython-39.pyc differ diff --git a/backend/app/func.py b/backend/app/func.py index 0cabde8..77cebff 100644 --- a/backend/app/func.py +++ b/backend/app/func.py @@ -39,7 +39,7 @@ async def analyze_pt_file(file: UploadFile): # 2. gaze tracking try: - gaze_result = analyze_gaze(temp_video_path, 'output2.mp4') + gaze_result = analyze_gaze(temp_video_path) print("눈동자 추적 분석 결과:", gaze_result) except Exception as e: print(f"오류 발생: {e}") diff --git a/backend/app/models/speech/__pycache__/speech_analysis.cpython-39.pyc b/backend/app/models/speech/__pycache__/speech_analysis.cpython-39.pyc new file mode 100644 index 0000000..e755c0c Binary files /dev/null and b/backend/app/models/speech/__pycache__/speech_analysis.cpython-39.pyc differ diff --git a/backend/app/models/text/__pycache__/__init__.cpython-311.pyc b/backend/app/models/text/__pycache__/__init__.cpython-311.pyc index bf2c698..2144582 100644 Binary files a/backend/app/models/text/__pycache__/__init__.cpython-311.pyc and b/backend/app/models/text/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/app/models/text/__pycache__/__init__.cpython-39.pyc b/backend/app/models/text/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..de73099 Binary files /dev/null and b/backend/app/models/text/__pycache__/__init__.cpython-39.pyc differ diff --git a/backend/app/models/text/__pycache__/extraction.cpython-311.pyc b/backend/app/models/text/__pycache__/extraction.cpython-311.pyc index 52eeb67..1083ef4 100644 Binary files a/backend/app/models/text/__pycache__/extraction.cpython-311.pyc and b/backend/app/models/text/__pycache__/extraction.cpython-311.pyc differ diff --git a/backend/app/models/text/__pycache__/extraction.cpython-39.pyc b/backend/app/models/text/__pycache__/extraction.cpython-39.pyc new file mode 100644 index 0000000..aaaa65e Binary files /dev/null and b/backend/app/models/text/__pycache__/extraction.cpython-39.pyc differ diff --git a/backend/app/models/text/__pycache__/summarization.cpython-311.pyc b/backend/app/models/text/__pycache__/summarization.cpython-311.pyc index a3a24fc..cc515c3 100644 Binary files a/backend/app/models/text/__pycache__/summarization.cpython-311.pyc and b/backend/app/models/text/__pycache__/summarization.cpython-311.pyc differ diff --git a/backend/app/models/text/__pycache__/summarization.cpython-39.pyc b/backend/app/models/text/__pycache__/summarization.cpython-39.pyc new file mode 100644 index 0000000..010cff2 Binary files /dev/null and b/backend/app/models/text/__pycache__/summarization.cpython-39.pyc differ diff --git a/backend/app/models/text/hanspell/__pycache__/__init__.cpython-311.pyc b/backend/app/models/text/hanspell/__pycache__/__init__.cpython-311.pyc index 744547c..4e1afde 100644 Binary files a/backend/app/models/text/hanspell/__pycache__/__init__.cpython-311.pyc and b/backend/app/models/text/hanspell/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/app/models/text/hanspell/__pycache__/__init__.cpython-39.pyc b/backend/app/models/text/hanspell/__pycache__/__init__.cpython-39.pyc index 34f1c1e..94c28a1 100644 Binary files a/backend/app/models/text/hanspell/__pycache__/__init__.cpython-39.pyc and b/backend/app/models/text/hanspell/__pycache__/__init__.cpython-39.pyc differ diff --git a/backend/app/models/text/hanspell/__pycache__/constants.cpython-311.pyc b/backend/app/models/text/hanspell/__pycache__/constants.cpython-311.pyc index 5b808cd..bb0cf8e 100644 Binary files a/backend/app/models/text/hanspell/__pycache__/constants.cpython-311.pyc and b/backend/app/models/text/hanspell/__pycache__/constants.cpython-311.pyc differ diff --git a/backend/app/models/text/hanspell/__pycache__/constants.cpython-39.pyc b/backend/app/models/text/hanspell/__pycache__/constants.cpython-39.pyc index 2ddf557..166f50f 100644 Binary files a/backend/app/models/text/hanspell/__pycache__/constants.cpython-39.pyc and b/backend/app/models/text/hanspell/__pycache__/constants.cpython-39.pyc differ diff --git a/backend/app/models/text/hanspell/__pycache__/response.cpython-311.pyc b/backend/app/models/text/hanspell/__pycache__/response.cpython-311.pyc index dabe703..216e0aa 100644 Binary files a/backend/app/models/text/hanspell/__pycache__/response.cpython-311.pyc and b/backend/app/models/text/hanspell/__pycache__/response.cpython-311.pyc differ diff --git a/backend/app/models/text/hanspell/__pycache__/response.cpython-39.pyc b/backend/app/models/text/hanspell/__pycache__/response.cpython-39.pyc index 5a83f80..e1fdf0b 100644 Binary files a/backend/app/models/text/hanspell/__pycache__/response.cpython-39.pyc and b/backend/app/models/text/hanspell/__pycache__/response.cpython-39.pyc differ diff --git a/backend/app/models/text/hanspell/__pycache__/spell_checker.cpython-311.pyc b/backend/app/models/text/hanspell/__pycache__/spell_checker.cpython-311.pyc index 13ca002..d3eacbc 100644 Binary files a/backend/app/models/text/hanspell/__pycache__/spell_checker.cpython-311.pyc and b/backend/app/models/text/hanspell/__pycache__/spell_checker.cpython-311.pyc differ diff --git a/backend/app/models/text/hanspell/__pycache__/spell_checker.cpython-39.pyc b/backend/app/models/text/hanspell/__pycache__/spell_checker.cpython-39.pyc index a868001..6abf458 100644 Binary files a/backend/app/models/text/hanspell/__pycache__/spell_checker.cpython-39.pyc and b/backend/app/models/text/hanspell/__pycache__/spell_checker.cpython-39.pyc differ diff --git a/backend/app/models/video/emotion_recognition/__pycache__/__init__.cpython-311.pyc b/backend/app/models/video/emotion_recognition/__pycache__/__init__.cpython-311.pyc index a7081e1..c493e9a 100644 Binary files a/backend/app/models/video/emotion_recognition/__pycache__/__init__.cpython-311.pyc and b/backend/app/models/video/emotion_recognition/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/app/models/video/emotion_recognition/__pycache__/__init__.cpython-39.pyc b/backend/app/models/video/emotion_recognition/__pycache__/__init__.cpython-39.pyc index f04733a..40eea61 100644 Binary files a/backend/app/models/video/emotion_recognition/__pycache__/__init__.cpython-39.pyc and b/backend/app/models/video/emotion_recognition/__pycache__/__init__.cpython-39.pyc differ diff --git a/backend/app/models/video/emotion_recognition/__pycache__/onnx_inference.cpython-311.pyc b/backend/app/models/video/emotion_recognition/__pycache__/onnx_inference.cpython-311.pyc index d19902b..0b8a26d 100644 Binary files a/backend/app/models/video/emotion_recognition/__pycache__/onnx_inference.cpython-311.pyc and b/backend/app/models/video/emotion_recognition/__pycache__/onnx_inference.cpython-311.pyc differ diff --git a/backend/app/models/video/emotion_recognition/__pycache__/onnx_inference.cpython-39.pyc b/backend/app/models/video/emotion_recognition/__pycache__/onnx_inference.cpython-39.pyc index 5a8e167..c596a31 100644 Binary files a/backend/app/models/video/emotion_recognition/__pycache__/onnx_inference.cpython-39.pyc and b/backend/app/models/video/emotion_recognition/__pycache__/onnx_inference.cpython-39.pyc differ diff --git a/backend/app/models/video/eye_tracking/__pycache__/__init__.cpython-311.pyc b/backend/app/models/video/eye_tracking/__pycache__/__init__.cpython-311.pyc index c7227f3..6047ca3 100644 Binary files a/backend/app/models/video/eye_tracking/__pycache__/__init__.cpython-311.pyc and b/backend/app/models/video/eye_tracking/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/app/models/video/eye_tracking/__pycache__/__init__.cpython-39.pyc b/backend/app/models/video/eye_tracking/__pycache__/__init__.cpython-39.pyc index 8e68000..ee3eb20 100644 Binary files a/backend/app/models/video/eye_tracking/__pycache__/__init__.cpython-39.pyc and b/backend/app/models/video/eye_tracking/__pycache__/__init__.cpython-39.pyc differ diff --git a/backend/app/models/video/eye_tracking/__pycache__/example.cpython-311.pyc b/backend/app/models/video/eye_tracking/__pycache__/example.cpython-311.pyc index 98b8aab..1828714 100644 Binary files a/backend/app/models/video/eye_tracking/__pycache__/example.cpython-311.pyc and b/backend/app/models/video/eye_tracking/__pycache__/example.cpython-311.pyc differ diff --git a/backend/app/models/video/eye_tracking/__pycache__/example.cpython-39.pyc b/backend/app/models/video/eye_tracking/__pycache__/example.cpython-39.pyc new file mode 100644 index 0000000..01d13f2 Binary files /dev/null and b/backend/app/models/video/eye_tracking/__pycache__/example.cpython-39.pyc differ diff --git a/backend/app/models/video/eye_tracking/example.py b/backend/app/models/video/eye_tracking/example.py index a04f6e4..998e05c 100644 --- a/backend/app/models/video/eye_tracking/example.py +++ b/backend/app/models/video/eye_tracking/example.py @@ -4,18 +4,20 @@ gaze = GazeTracking() -def analyze_gaze(video_path:str, output_path:str)->List[str]: +def analyze_gaze(video_path:str)->List[str]: # video_path = 'minute.mp4' video_capture = cv2.VideoCapture(video_path) - + if not video_capture.isOpened(): + print(f"비디오 파일을 열 수 없습니다: {video_path}") + return # 영상 저장 설정 - output_path = 'output2.mp4' - fourcc = cv2.VideoWriter_fourcc(*'mp4v') - fps = int(video_capture.get(cv2.CAP_PROP_FPS)) - frame_width = int(video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)) - frame_height = int(video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) - out = cv2.VideoWriter(output_path, fourcc, fps, (frame_width, frame_height)) + #output_path = 'output2.mp4' + #fourcc = cv2.VideoWriter_fourcc(*'mp4v') + #fps = int(video_capture.get(cv2.CAP_PROP_FPS)) + #frame_width = int(video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)) + #frame_height = int(video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT)) + #out = cv2.VideoWriter(output_path, fourcc, fps, (frame_width, frame_height)) unstable_gaze_count = 0 tracking_started = False @@ -37,8 +39,8 @@ def analyze_gaze(video_path:str, output_path:str)->List[str]: result = [] - # 30초에 해당하는 프레임 수 (30초동안 눈 10회 이상 깜빡이는지 보려고. 사람 평균이 1분에 20회라고 함) - frames_per_30sec = 15 + # 20초에 해당하는 프레임 수 (20초동안 눈 8회 이상 깜빡이는지 보려고. 사람 평균이 1분에 20회라고 함) + frames_per_20sec = 8 while True: # 프레임 읽기 @@ -46,6 +48,7 @@ def analyze_gaze(video_path:str, output_path:str)->List[str]: # 모든 프레임을 읽었을 때 종료 if not ret: + print("프레임을 읽을 수 없습니다.") break # GazeTracking을 사용하여 프레임 분석 @@ -76,23 +79,29 @@ def analyze_gaze(video_path:str, output_path:str)->List[str]: if tracking_started and unstable_gaze_count >= 6: text0 = "시선이 불안정합니다" - # cv2.putText(frame, "Unstable gaze", (90, 190), cv2.FONT_HERSHEY_DUPLEX, 0.9, (147, 58, 31), 1) + #cv2.putText(frame, "Unstable gaze", (90, 190), cv2.FONT_HERSHEY_DUPLEX, 0.9, (147, 58, 31), 1) - cv2.putText(frame, text, (90, 60), cv2.FONT_HERSHEY_DUPLEX, 1.6, (147, 58, 31), 2) + #cv2.putText(frame, text, (90, 60), cv2.FONT_HERSHEY_DUPLEX, 1.6, (147, 58, 31), 2) left_pupil = gaze.pupil_left_coords() right_pupil = gaze.pupil_right_coords() - cv2.putText(frame, "Left pupil: " + str(left_pupil), (90, 130), cv2.FONT_HERSHEY_DUPLEX, 0.9, (147, 58, 31), 1) - cv2.putText(frame, "Right pupil: " + str(right_pupil), (90, 165), cv2.FONT_HERSHEY_DUPLEX, 0.9, (147, 58, 31), - 1) + #cv2.putText(frame, "Left pupil: " + str(left_pupil), (90, 130), cv2.FONT_HERSHEY_DUPLEX, 0.9, (147, 58, 31), 1) + #cv2.putText(frame, "Right pupil: " + str(right_pupil), (90, 165), cv2.FONT_HERSHEY_DUPLEX, 0.9, (147, 58, 31), + # 1) # 경과 시간 계산 elapsed_frames = int(video_capture.get(cv2.CAP_PROP_POS_FRAMES)) # 경과 프레임 수 elapsed_seconds = elapsed_frames / fps # 경과 초 if elapsed_seconds > video_length_seconds - 5: - blink_rate_in_30sec = blink_count / (elapsed_seconds / 30) - if blink_rate_in_30sec > frames_per_30sec: + if elapsed_seconds > 0: + blink_rate_in_20sec = blink_count / (elapsed_seconds / 20) + else: + # 적절한 오류 처리 또는 대체 로직 + print("영상의 길이가 너무 짧습니다.") + return [] + #blink_rate_in_20sec = blink_count / (elapsed_seconds / 20) + if blink_rate_in_20sec > frames_per_20sec: # 눈 깜빡임 횟수가 frames_per_minute보다 크면 "눈을 자주 깜빡입니다!" 메시지 출력 text1 = "눈 깜빡임이 잦습니다" @@ -106,13 +115,13 @@ def analyze_gaze(video_path:str, output_path:str)->List[str]: elif left // unstable_gaze_count > (2 / 3): text3 = "왼쪽으로 시선이 치우쳐집니다" - rate = blink_rate_in_30sec / 10 - # text2 = f'My blink frequency compared to the average person:{rate}' - text2 = rate + rate = blink_rate_in_20sec / 8 + + text2 = f"평균대비 눈 깜빡임 비율: {rate:.2f}" - # cv2.putText(frame, text1, (90, 480), cv2.FONT_HERSHEY_DUPLEX, 0.9, (0, 0, 255), 1) - # cv2.putText(frame, text2, (90, 530), cv2.FONT_HERSHEY_DUPLEX, 0.9, (0, 0, 255), 1) - # cv2.putText(frame, text3, (90, 580), cv2.FONT_HERSHEY_DUPLEX, 0.9, (0, 0, 255), 1) + #cv2.putText(frame, text1, (90, 480), cv2.FONT_HERSHEY_DUPLEX, 0.9, (0, 0, 255), 1) + #cv2.putText(frame, str(text2), (90, 530), cv2.FONT_HERSHEY_DUPLEX, 0.9, (0, 0, 255), 1) + #cv2.putText(frame, text3, (90, 580), cv2.FONT_HERSHEY_DUPLEX, 0.9, (0, 0, 255), 1) #cv2.imshow("Demo", frame) @@ -124,13 +133,15 @@ def analyze_gaze(video_path:str, output_path:str)->List[str]: result = [text0, text1, text2, text3] if text0!="": text0="시선이 불안정하며 " + if text3=="": + text3=" 시선처리가 특정방향으로 쏠리지 않으며 정면을 잘 응시합니다. " # rate 값을 소수점 둘째 자리까지 포매팅 - rate_formatted = "{:.2f}".format(rate) - ment2=" 평균대비 눈 깜빡임이 "+rate_formatted+"로 " - ment=text0+text3+ment2+text1 + + + ment=f"{text0} {text3} 평균대비 눈 깜빡임이 {rate:.2f}로 {text1}" - out.release() - video_capture.release() - cv2.destroyAllWindows() + #out.release() + #video_capture.release() + #cv2.destroyAllWindows() - return ment + return [ment] diff --git a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/__init__.cpython-311.pyc b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/__init__.cpython-311.pyc index 1251d0b..671d395 100644 Binary files a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/__init__.cpython-311.pyc and b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/__init__.cpython-311.pyc differ diff --git a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/__init__.cpython-39.pyc b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..8e620a7 Binary files /dev/null and b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/__init__.cpython-39.pyc differ diff --git a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/calibration.cpython-39.pyc b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/calibration.cpython-39.pyc new file mode 100644 index 0000000..f561e7d Binary files /dev/null and b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/calibration.cpython-39.pyc differ diff --git a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/eye.cpython-39.pyc b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/eye.cpython-39.pyc new file mode 100644 index 0000000..6b38c4f Binary files /dev/null and b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/eye.cpython-39.pyc differ diff --git a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/gaze_tracking.cpython-311.pyc b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/gaze_tracking.cpython-311.pyc index 971bdd7..f42b54d 100644 Binary files a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/gaze_tracking.cpython-311.pyc and b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/gaze_tracking.cpython-311.pyc differ diff --git a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/gaze_tracking.cpython-39.pyc b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/gaze_tracking.cpython-39.pyc new file mode 100644 index 0000000..aa67d60 Binary files /dev/null and b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/gaze_tracking.cpython-39.pyc differ diff --git a/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/pupil.cpython-39.pyc b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/pupil.cpython-39.pyc new file mode 100644 index 0000000..57995b7 Binary files /dev/null and b/backend/app/models/video/eye_tracking/gaze_tracking/__pycache__/pupil.cpython-39.pyc differ diff --git a/backend/app/models/video/eye_tracking/gaze_tracking/pupil.py b/backend/app/models/video/eye_tracking/gaze_tracking/pupil.py index 8e29ed5..0817d37 100644 --- a/backend/app/models/video/eye_tracking/gaze_tracking/pupil.py +++ b/backend/app/models/video/eye_tracking/gaze_tracking/pupil.py @@ -30,6 +30,10 @@ def image_processing(eye_frame, threshold): Returns: A frame with a single element representing the iris """ + if eye_frame is None or eye_frame.size == 0: + print("빈 프레임이 전달되었습니다.") + return None # 또는 다른 적절한 반환값 + kernel = np.ones((3, 3), np.uint8) new_frame = cv2.bilateralFilter(eye_frame, 10, 15, 15) new_frame = cv2.erode(new_frame, kernel, iterations=3) diff --git a/backend/app/output2.mp4 b/backend/app/output2.mp4 index bc3e8df..566a00f 100644 Binary files a/backend/app/output2.mp4 and b/backend/app/output2.mp4 differ diff --git a/frontend/static/js/upload.js b/frontend/static/js/upload.js index ce9f5c4..f3359f5 100644 --- a/frontend/static/js/upload.js +++ b/frontend/static/js/upload.js @@ -1,281 +1,301 @@ function processAudio() { - var audioInput = document.getElementById('audioUpload'); - var resultDiv = document.getElementById('result_font1'); + var audioInput = document.getElementById("audioUpload"); + var resultDiv = document.getElementById("result_font1"); if (audioInput.files.length > 0) { - var audioFile = audioInput.files[0]; + var audioFile = audioInput.files[0]; - // Process the audio file - // For example, read the file name and size - var fileInfo = `File Name: ${audioFile.name}, File Size: ${audioFile.size} bytes`; + // Process the audio file + // For example, read the file name and size + var fileInfo = `File Name: ${audioFile.name}, File Size: ${audioFile.size} bytes`; - // Display results - resultDiv.innerHTML = fileInfo; + // Display results + resultDiv.innerHTML = fileInfo; - // You can add more complex processing here, - // like analyzing the audio file, playing it, - // or sending it to a server for further processing. + // You can add more complex processing here, + // like analyzing the audio file, playing it, + // or sending it to a server for further processing. } else { - resultDiv.innerHTML = 'No file selected'; + resultDiv.innerHTML = "No file selected"; } } let oldOnclick; async function uploadFile() { - const fileInput = document.getElementById('audioFile'); - const file = fileInput.files[0]; - - // Provide feedback that a file has been selected - const upload_btn = document.querySelector('.custom_upload_btn'); - document.getElementById('result_font1').style.display = 'none'; - document.getElementById('result_font2').style.display = 'none'; - document.getElementById("mask0_39_984").style.display = 'none'; - document.querySelector('.svg1').style.display = 'none'; - oldOnclick = upload_btn.onclick; - upload_btn.onclick = null; - upload_btn.style.border='2px solid #DFDFDF'; - upload_btn.style.background = '#FFF'; - - const svgElement = createSvgElement('svg', { - 'width': '29px', - 'height': '37px', - 'flex-shrink': '0', - 'viewBox': '0 0 30 38', - 'fill': 'none', - 'id': 'mov_svg'} - ); - - const paths = [ - {'d': "M19.9189 0L24.5667 4.64773L29.2144 9.29545H19.9189V0Z", 'fill':'#92DBFF' }, - {'d' : "M2 0C0.895431 0 0 0.895433 0 2V35.1818C0 36.2864 0.89543 37.1818 2 37.1818H27.2143C28.3189 37.1818 29.2143 36.2864 29.2143 35.1818V9.29545H19.9189V0H2Z" - , 'fill': '#00A8F4', 'fill-rule': 'evenodd', 'clip-rule': 'evenodd' }, - { 'd': "M21.6737 23.3921L23.3788 18.1973H24.6934L22.5183 24.7466H20.8372L18.6541 18.1973H19.9687L21.6737 23.3921Z", 'fill' : 'white' }, - { 'd' : "M15.7252 24.8665C15.2099 24.8665 14.7345 24.7523 14.299 24.5239C13.8634 24.3008 13.5155 23.9768 13.2552 23.5518C13.0003 23.1216 12.8728 22.6143 12.8728 22.03V20.9146C12.8728 20.3356 13.0003 19.831 13.2552 19.4007C13.5155 18.9705 13.8634 18.6438 14.299 18.4207C14.7345 18.1923 15.2099 18.0781 15.7252 18.0781C16.2404 18.0781 16.7158 18.1923 17.1514 18.4207C17.5869 18.6438 17.9322 18.9705 18.1871 19.4007C18.4474 19.831 18.5776 20.3356 18.5776 20.9146V22.03C18.5776 22.6143 18.4474 23.1216 18.1871 23.5518C17.9322 23.9768 17.5869 24.3008 17.1514 24.5239C16.7158 24.7523 16.2404 24.8665 15.7252 24.8665ZM15.7252 23.7032C16.0173 23.7032 16.2856 23.6395 16.5299 23.512C16.7742 23.3792 16.9681 23.1827 17.1115 22.9224C17.2549 22.6621 17.3267 22.3487 17.3267 21.9822V20.9624C17.3267 20.5959 17.2523 20.2851 17.1036 20.0302C16.9601 19.7699 16.7663 19.5734 16.5219 19.4406C16.2829 19.3078 16.0173 19.2414 15.7252 19.2414C15.433 19.2414 15.1648 19.3078 14.9205 19.4406C14.6814 19.5734 14.4876 19.7699 14.3388 20.0302C14.1954 20.2851 14.1237 20.5959 14.1237 20.9624V21.9822C14.1237 22.3487 14.1954 22.6621 14.3388 22.9224C14.4876 23.1827 14.6814 23.3792 14.9205 23.512C15.1648 23.6395 15.433 23.7032 15.7252 23.7032Z", 'fill' : 'white'}, - { 'd' : "M6.18525 24.7466H4.95825V18.1973H6.62347L8.49584 23.1929L10.3682 18.1973H12.0334V24.7466H10.8064V20.2529L9.1173 24.7466H7.87437L6.18525 20.2529V24.7466Z", 'fill' : 'white' } - ] - paths.forEach(path => { - svgElement.appendChild(createSvgElement('path',path)) + const fileInput = document.getElementById("audioFile"); + const file = fileInput.files[0]; + + // Provide feedback that a file has been selected + const upload_btn = document.querySelector(".custom_upload_btn"); + document.getElementById("result_font1").style.display = "none"; + document.getElementById("result_font2").style.display = "none"; + document.getElementById("mask0_39_984").style.display = "none"; + document.querySelector(".svg1").style.display = "none"; + oldOnclick = upload_btn.onclick; + upload_btn.onclick = null; + upload_btn.style.border = "2px solid #DFDFDF"; + upload_btn.style.background = "#FFF"; + + const svgElement = createSvgElement("svg", { + width: "29px", + height: "37px", + "flex-shrink": "0", + viewBox: "0 0 30 38", + fill: "none", + id: "mov_svg" + }); + + const paths = [ + { + d: "M19.9189 0L24.5667 4.64773L29.2144 9.29545H19.9189V0Z", + fill: "#92DBFF" + }, + { + d: "M2 0C0.895431 0 0 0.895433 0 2V35.1818C0 36.2864 0.89543 37.1818 2 37.1818H27.2143C28.3189 37.1818 29.2143 36.2864 29.2143 35.1818V9.29545H19.9189V0H2Z", + fill: "#00A8F4", + "fill-rule": "evenodd", + "clip-rule": "evenodd" + }, + { + d: "M21.6737 23.3921L23.3788 18.1973H24.6934L22.5183 24.7466H20.8372L18.6541 18.1973H19.9687L21.6737 23.3921Z", + fill: "white" + }, + { + d: "M15.7252 24.8665C15.2099 24.8665 14.7345 24.7523 14.299 24.5239C13.8634 24.3008 13.5155 23.9768 13.2552 23.5518C13.0003 23.1216 12.8728 22.6143 12.8728 22.03V20.9146C12.8728 20.3356 13.0003 19.831 13.2552 19.4007C13.5155 18.9705 13.8634 18.6438 14.299 18.4207C14.7345 18.1923 15.2099 18.0781 15.7252 18.0781C16.2404 18.0781 16.7158 18.1923 17.1514 18.4207C17.5869 18.6438 17.9322 18.9705 18.1871 19.4007C18.4474 19.831 18.5776 20.3356 18.5776 20.9146V22.03C18.5776 22.6143 18.4474 23.1216 18.1871 23.5518C17.9322 23.9768 17.5869 24.3008 17.1514 24.5239C16.7158 24.7523 16.2404 24.8665 15.7252 24.8665ZM15.7252 23.7032C16.0173 23.7032 16.2856 23.6395 16.5299 23.512C16.7742 23.3792 16.9681 23.1827 17.1115 22.9224C17.2549 22.6621 17.3267 22.3487 17.3267 21.9822V20.9624C17.3267 20.5959 17.2523 20.2851 17.1036 20.0302C16.9601 19.7699 16.7663 19.5734 16.5219 19.4406C16.2829 19.3078 16.0173 19.2414 15.7252 19.2414C15.433 19.2414 15.1648 19.3078 14.9205 19.4406C14.6814 19.5734 14.4876 19.7699 14.3388 20.0302C14.1954 20.2851 14.1237 20.5959 14.1237 20.9624V21.9822C14.1237 22.3487 14.1954 22.6621 14.3388 22.9224C14.4876 23.1827 14.6814 23.3792 14.9205 23.512C15.1648 23.6395 15.433 23.7032 15.7252 23.7032Z", + fill: "white" + }, + { + d: "M6.18525 24.7466H4.95825V18.1973H6.62347L8.49584 23.1929L10.3682 18.1973H12.0334V24.7466H10.8064V20.2529L9.1173 24.7466H7.87437L6.18525 20.2529V24.7466Z", + fill: "white" + } + ]; + paths.forEach((path) => { + svgElement.appendChild(createSvgElement("path", path)); + }); + svgElement.id = "mov_svg"; + + const newBox = document.createElement("div"); + newBox.id = "newBox"; + + const newBox2 = document.createElement("div"); + newBox2.className = "newBox2"; + newBox2.onclick = anal; + newBox2.style.display = "block"; + + const fileSizeInMB = file.size / 1024 / 1024; + + const fileNameElement = document.createElement("div"); + fileNameElement.id = "fileNameElementId"; + var file_name = truncateText(file.name, 18); + fileNameElement.innerText = file_name; + + const fileNameElement2 = document.createElement("div"); + fileNameElement2.id = "fileNameElementId2"; + fileNameElement2.innerText = "분석하기"; + + const fileNameElement3 = document.createElement("div"); + fileNameElement3.id = "fileNameElementId3"; + fileNameElement3.innerText = fileSizeInMB.toFixed(2) + "MB"; + + newBox.appendChild(fileNameElement); + newBox.appendChild(svgElement); + newBox.appendChild(fileNameElement3); + newBox2.appendChild(fileNameElement2); + upload_btn.appendChild(newBox); + upload_btn.appendChild(newBox2); + + document.getElementsByClassName("delete_svg")[0].style.display = "block"; + + const formData = new FormData(); + formData.append("file", file); + + function result() { + document.getElementById("spinner").style.display = "none"; + document.getElementById("result_font3").style.display = "none"; + document.querySelector(".svg4").style.display = "block"; + document.getElementById("resultBox").style.display = "block"; + const analBox = document.querySelector(".custom_upload_btn"); + const resulttext = document.createElement("div"); + resulttext.id = "result_font3"; + resulttext.innerText = "분석 완료"; + analBox.appendChild(resulttext); + analBox.style.border = "2px solid #DFDFDF"; + analBox.style.background = "#FCFCFC"; + + const fileNameElement = document.createElement("div"); + fileNameElement.id = "fileNameElementId"; + var file_name = truncateText(file.name, 18); + fileNameElement.innerText = file_name; + + const fileNameElement3 = document.createElement("div"); + fileNameElement3.id = "fileNameElementId3"; + + const fileSizeInMB = file.size / 1024 / 1024; + fileNameElement3.innerText = fileSizeInMB.toFixed(2) + "MB"; + resultBox.appendChild(fileNameElement); + resultBox.appendChild(fileNameElement3); + + svgElement.id = "result_svg"; + resultBox.appendChild(svgElement); + } + async function anal() { + document.getElementById("spinner").style.display = "block"; + const analBox = document.querySelector(".custom_upload_btn"); + analBox.style.cursor = "default"; + const analtext = document.createElement("div"); + analtext.id = "result_font3"; + analtext.innerText = "분석 중..."; + analBox.appendChild(analtext); + document.getElementsByClassName("delete_svg")[0].style.display = "none"; + analBox.style.border = "2px solid #DFDFDF"; + analBox.style.background = "#FCFCFC"; + analBox.style.position = "absolute"; + analBox.removeChild(newBox); + analBox.removeChild(newBox2); + + try { + const response = await fetch("http://127.0.0.1:8000/detect_pt/", { + method: "POST", + body: formData }); - svgElement.id = 'mov_svg'; - - const newBox = document.createElement('div'); - newBox.id = 'newBox'; - - const newBox2 = document.createElement('div'); - newBox2.className = 'newBox2'; - newBox2.onclick = anal; - newBox2.style.display = 'block'; - - - const fileSizeInMB = file.size/1024/1024; - - const fileNameElement = document.createElement('div'); - fileNameElement.id = 'fileNameElementId'; - var file_name = truncateText(file.name,18); - fileNameElement.innerText = file_name; - - const fileNameElement2 = document.createElement('div'); - fileNameElement2.id = 'fileNameElementId2'; - fileNameElement2.innerText = '분석하기' - - const fileNameElement3 = document.createElement('div'); - fileNameElement3.id = 'fileNameElementId3'; - fileNameElement3.innerText = fileSizeInMB.toFixed(2)+'MB'; - - newBox.appendChild(fileNameElement); - newBox.appendChild(svgElement); - newBox.appendChild(fileNameElement3); - newBox2.appendChild(fileNameElement2); - upload_btn.appendChild(newBox); - upload_btn.appendChild(newBox2); - - document.getElementsByClassName('delete_svg')[0].style.display = 'block'; - - const formData = new FormData(); - formData.append('file', file); - - function result() { - document.getElementById('spinner').style.display = 'none'; - document.getElementById('result_font3').style.display = 'none' - document.querySelector('.svg4').style.display = 'block'; - document.getElementById('resultBox').style.display = 'block'; - const analBox = document.querySelector('.custom_upload_btn'); - const resulttext = document.createElement('div'); - resulttext.id = 'result_font3'; - resulttext.innerText = '분석 완료'; - analBox.appendChild(resulttext); - analBox.style.border='2px solid #DFDFDF'; - analBox.style.background = '#FCFCFC'; - - const fileNameElement = document.createElement('div'); - fileNameElement.id = 'fileNameElementId'; - var file_name = truncateText(file.name,18) - fileNameElement.innerText = file_name; - - const fileNameElement3 = document.createElement('div'); - fileNameElement3.id = 'fileNameElementId3'; - - const fileSizeInMB = file.size/1024/1024; - fileNameElement3.innerText = fileSizeInMB.toFixed(2)+'MB'; - resultBox.appendChild(fileNameElement); - resultBox.appendChild(fileNameElement3); - - svgElement.id = 'result_svg'; - resultBox.appendChild(svgElement); - } - async function anal() { - document.getElementById('spinner').style.display = 'block'; - const analBox = document.querySelector('.custom_upload_btn'); - analBox.style.cursor = 'default'; - const analtext = document.createElement('div'); - analtext.id = 'result_font3'; - analtext.innerText = '분석 중...'; - analBox.appendChild(analtext); - document.getElementsByClassName('delete_svg')[0].style.display = 'none'; - analBox.style.border='2px solid #DFDFDF'; - analBox.style.background = '#FCFCFC'; - analBox.style.position = 'absolute'; - analBox.removeChild(newBox); - analBox.removeChild(newBox2); - - try { - const response = await fetch('http://127.0.0.1:8000/detect_pt/', { - method: 'POST', - body: formData - }); - if (response.ok) { - const data = await response.json(); - result(); - console.log('Analysis complete:', data); - - // 결과를 출력하고자 하는 HTML 요소들을 선택 - const lineBox2 = document.querySelector('.line-box-2'); - const lineBox4 = document.querySelector('.line-box-4'); - const lineBox6 = document.querySelector('.line-box-6'); - const lineBox8 = document.querySelector('.line-box-8'); - const lineBox10 = document.querySelector('.line-box-10'); - - // 각각의 HTML 요소에 결과를 추가 - const resultElement2 = document.createElement('div'); - resultElement2.textContent = '분석 결과: ' + data.result2; - lineBox2.appendChild(resultElement2); - - const resultElement4 = document.createElement('div'); - resultElement4.textContent = '분석 결과: ' + data.result4; - lineBox4.appendChild(resultElement4); - - const resultElement6 = document.createElement('div'); - resultElement6.textContent = '분석 결과: ' + data.result6; - lineBox6.appendChild(resultElement6); - - const resultElement8 = document.createElement('div'); - resultElement8.textContent = '분석 결과: ' + data.result8; - lineBox8.appendChild(resultElement8); - - const resultElement10 = document.createElement('div'); - resultElement10.textContent = '분석 결과: ' + data.result10; - lineBox10.appendChild(resultElement10); - } else { - throw new Error('Failed to fetch analysis result'); - } - } catch (error) { - console.error('Error:', error); - alert(error); + if (response.ok) { + const data = await response.json(); + result(); + console.log("Analysis complete:", data); + + // 결과를 출력하고자 하는 HTML 요소들을 선택 + const lineBox2 = document.querySelector(".line-box-2"); + const lineBox4 = document.querySelector(".line-box-4"); + const lineBox6 = document.querySelector(".line-box-6"); + const lineBox8 = document.querySelector(".line-box-8"); + const lineBox10 = document.querySelector(".line-box-10"); + + // Display emotion analysis + const emotionAnalysis = data.emotion.emotion.join(", "); + const emotionElement = document.createElement("div"); + emotionElement.textContent = emotionAnalysis; + lineBox2.appendChild(emotionElement); + + // Display speech speed + const speechSpeedElement = document.createElement("div"); + speechSpeedElement.textContent = data.speech.speed; + lineBox4.appendChild(speechSpeedElement); + + // Display number of pauses + const numPausesElement = document.createElement("div"); + numPausesElement.textContent = data.speech.num_pauses; + lineBox6.appendChild(numPausesElement); + + // Display filler words + // Assuming filler words are an object where each property is a filler word and its value is the count + const fillerWords = data.speech.filler_words; + const fillerWordsText = Object.entries(fillerWords) + .map(([word, count]) => `${word}: ${count}번`) + .join(", "); + const fillerWordsElement = document.createElement("div"); + fillerWordsElement.textContent = fillerWordsText; + lineBox8.appendChild(fillerWordsElement); + } else { + throw new Error("Failed to fetch analysis result"); } + } catch (error) { + console.error("Error:", error); + alert(error); + } } - +} +/* // 파일 업로드 input 요소의 change 이벤트를 처리하는 함수 function handleFileInputChange(event) { const file = event.target.files[0]; if (file) { - handleFileUpload(file); + handleFileUpload(file); } } // 파일 업로드 input 요소에 change 이벤트 리스너 추가 -const fileInput = document.getElementById('fileInput'); -fileInput.addEventListener('change', handleFileInputChange); - - +const fileInput = document.getElementById("fileInput"); +fileInput.addEventListener("change", handleFileInputChange); +*/ function createSvgElement(elementType, attributes) { -const element = document.createElementNS('http://www.w3.org/2000/svg', elementType); -for (let key in attributes) { + const element = document.createElementNS( + "http://www.w3.org/2000/svg", + elementType + ); + for (let key in attributes) { element.setAttribute(key, attributes[key]); + } + return element; } -return element; -} - async function removeFile() { - const fileInput = document.getElementById('audioFile'); - fileInput.value = ''; - document.getElementsByClassName('delete_svg')[0].style.display = 'none'; - const uploadButton = document.querySelector('.custom_upload_btn'); - const newBox2 = document.querySelector('.newBox2'); - uploadButton.style.backgroundColor = ''; - uploadButton.style.border = ''; - uploadButton.style.width = ''; - uploadButton.style.height = ''; + const fileInput = document.getElementById("audioFile"); + fileInput.value = ""; + document.getElementsByClassName("delete_svg")[0].style.display = "none"; + const uploadButton = document.querySelector(".custom_upload_btn"); + const newBox2 = document.querySelector(".newBox2"); + uploadButton.style.backgroundColor = ""; + uploadButton.style.border = ""; + uploadButton.style.width = ""; + uploadButton.style.height = ""; uploadButton.onclick = oldOnclick; - uploadButton.style.cursor = 'pointer'; + uploadButton.style.cursor = "pointer"; - // SVG 아이콘과 텍스트를 다시 보이게 합니다. - document.querySelector('.svg1').style.display = ''; - document.getElementById('result_font1').style.display = ''; - document.getElementById('result_font2').style.display = ''; - document.getElementById("mask0_39_984").style.display = ''; - document.getElementById('result_font1').innerText = '분석할 발표 영상을 업로드 해주세요'; - + document.querySelector(".svg1").style.display = ""; + document.getElementById("result_font1").style.display = ""; + document.getElementById("result_font2").style.display = ""; + document.getElementById("mask0_39_984").style.display = ""; + document.getElementById("result_font1").innerText = + "분석할 발표 영상을 업로드 해주세요"; + // 새롭게 추가한 박스를 제거합니다. - + uploadButton.removeChild(newBox); uploadButton.removeChild(newBox2); } - function displayResult(result, sessionId) { - let resultsDiv = document.getElementById('analysisResults'); - if (!resultsDiv) { - // Create the results div if it does not exist - resultsDiv = document.createElement('div'); - resultsDiv.id = 'analysisResults'; - document.body.appendChild(resultsDiv); // Append somewhere suitable in your actual layout - } + let resultsDiv = document.getElementById("analysisResults"); + if (!resultsDiv) { + // Create the results div if it does not exist + resultsDiv = document.createElement("div"); + resultsDiv.id = "analysisResults"; + document.body.appendChild(resultsDiv); // Append somewhere suitable in your actual layout + } - // Update speed result - const speedResult = document.getElementById('result-speed'); - if (speedResult && result.speech && result.speech.speed) { - speedResult.textContent = `결과: 속도 ${result.speech.speed}`; - } + // Update speed result + const speedResult = document.getElementById("result-speed"); + if (speedResult && result.speech && result.speech.speed) { + speedResult.textContent = `결과: 속도 ${result.speech.speed}`; + } - // Update pause result - const pauseResult = document.getElementById('result-pause'); - if (pauseResult && result.speech && result.speech.num_pauses !== undefined) { - pauseResult.textContent = `결과: 일시정지 횟수 ${result.speech.num_pauses}`; - } + // Update pause result + const pauseResult = document.getElementById("result-pause"); + if (pauseResult && result.speech && result.speech.num_pauses !== undefined) { + pauseResult.textContent = `결과: 일시정지 횟수 ${result.speech.num_pauses}`; + } - // Update filler words result - const fillerWordsResult = document.getElementById('result-filler-words'); - if (fillerWordsResult && result.speech && result.speech.filler_words) { - const fillerWordsText = Object.entries(result.speech.filler_words) - .map(([word, count]) => `${word}: ${count}회`) - .join(', '); - fillerWordsResult.textContent = `결과: 보충어 ${fillerWordsText}`; - } + // Update filler words result + const fillerWordsResult = document.getElementById("result-filler-words"); + if (fillerWordsResult && result.speech && result.speech.filler_words) { + const fillerWordsText = Object.entries(result.speech.filler_words) + .map(([word, count]) => `${word}: ${count}회`) + .join(", "); + fillerWordsResult.textContent = `결과: 보충어 ${fillerWordsText}`; + } - const emotionResult = document.getElementById('result-emotion'); - if (speedResult && result.emotion && result.emotion.emtion) { - speedResult.textContent = `결과: 표정 ${result.emotion.emotion}`; - } + const emotionResult = document.getElementById("result-emotion"); + if (speedResult && result.emotion && result.emotion.emtion) { + speedResult.textContent = `결과: 표정 ${result.emotion.emotion}`; + } } - function truncateText(text, maxLength) { var truncated = text; if (truncated.length > maxLength) { - truncated = truncated.substr(0,maxLength-5) + ' · · · ' + truncated.substr(-5); + truncated = + truncated.substr(0, maxLength - 5) + " · · · " + truncated.substr(-5); } return truncated; } - diff --git a/frontend/templates/pt_upload.html b/frontend/templates/pt_upload.html index 8968f94..3731231 100644 --- a/frontend/templates/pt_upload.html +++ b/frontend/templates/pt_upload.html @@ -1,67 +1,157 @@
- - -