""" 실패 모달 컴포넌트 (Gradio 6 호환 버전) 커스텀 Modal 클래스 사용 👨💻 담당: 개발자 B """ import gradio as gr from frontend.components.custom_modal import Modal from frontend.renderers import render_radar_chart class FailureModalComponent: """실패 모달 컴포넌트 - custom_modal 사용""" def __init__(self): self.modal = None self.close_btn = None def render(self): """ 실패 모달 UI 렌더링 Returns: gr.HTML: modal_component """ self.modal = Modal( visible=False, content="", elem_id="failure-modal" ) modal_component = self.modal.render() return modal_component def setup_events(self, on_close=None): """ 이벤트 바인딩 (현재는 JS에서 처리) Args: on_close: 모달 닫힐 때 호출할 콜백 (미사용) """ # 모달 닫기는 JS에서 자동 처리됨 pass @staticmethod def create_modal_content( recognized_text: str, score: int, hint: str, audio_path: str = None, metrics: dict = None, user_text: str = None ) -> str: """ 모달 내용 HTML 생성 (오디오 재생 + 오각 그래프 + 점수표 + 조언) Args: recognized_text: 인식된 텍스트 score: 점수 hint: 힌트 메시지 audio_path: 제출한 오디오 파일 경로 metrics: 메트릭 데이터 {pronunciation, tone, pitch, rhythm, energy} user_text: 사용자가 말한 텍스트 (STT 결과) Returns: str: HTML 문자열 """ # 기본 메트릭 if metrics is None: metrics = {} # 점수에 따른 색상 결정 함수 def get_color(val): return "#e8a054" if val < 85 else "#4db8ff" # 사용자가 말한 텍스트 (STT 결과) HTML user_text_html = "" if user_text: user_text_html = f"""