Jeongsoo1975 commited on
Commit
94d3c15
·
1 Parent(s): 802cf81

fix: Optimize for Hugging Face Spaces deployment - Add Dockerfile and simplified app version - Fix app.launch() parameters for Spaces - Create fallback simple version without API dependencies

Browse files
Files changed (3) hide show
  1. Dockerfile +11 -0
  2. app.py +2 -7
  3. app_simple.py +87 -0
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . /code
10
+
11
+ CMD ["python", "app.py"]
app.py CHANGED
@@ -242,10 +242,5 @@ if __name__ == "__main__":
242
  # 인터페이스 생성
243
  app = create_interface()
244
 
245
- # 앱 실행
246
- app.launch(
247
- server_name="0.0.0.0",
248
- server_port=7860,
249
- share=True,
250
- show_error=True
251
- )
 
242
  # 인터페이스 생성
243
  app = create_interface()
244
 
245
+ # 앱 실행 (Hugging Face Spaces용)
246
+ app.launch()
 
 
 
 
 
app_simple.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ from datetime import datetime
4
+
5
+ def simple_text_separation(input_text):
6
+ """간단한 텍스트 화자 분리 (API 키 없이도 작동)"""
7
+ if not input_text.strip():
8
+ return "❌ 텍스트를 입력해주세요.", "", ""
9
+
10
+ # 간단한 분리 로직 (실제로는 AI 모델 필요)
11
+ sentences = input_text.split('.')
12
+
13
+ speaker1_lines = []
14
+ speaker2_lines = []
15
+
16
+ for i, sentence in enumerate(sentences):
17
+ sentence = sentence.strip()
18
+ if sentence:
19
+ if i % 2 == 0:
20
+ speaker1_lines.append(f"화자1: {sentence}.")
21
+ else:
22
+ speaker2_lines.append(f"화자2: {sentence}.")
23
+
24
+ separated_text = "\n".join(speaker1_lines + speaker2_lines)
25
+ speaker1_text = "\n".join(speaker1_lines)
26
+ speaker2_text = "\n".join(speaker2_lines)
27
+
28
+ status = f"""
29
+ ✅ **처리 완료!**
30
+ - 처리 시간: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
31
+ - 화자1 발언 수: {len(speaker1_lines)}개
32
+ - 화자2 발언 수: {len(speaker2_lines)}개
33
+
34
+ ⚠️ 현재 데모 모드입니다. AI 기반 처리를 위해서는 API 키가 필요합니다.
35
+ """
36
+
37
+ return status, separated_text, speaker1_text, speaker2_text
38
+
39
+ # Gradio 인터페이스
40
+ with gr.Blocks(title="2인 대화 화자 분리기") as app:
41
+ gr.HTML("""
42
+ <div style="text-align: center; margin-bottom: 20px;">
43
+ <h1>💬 2인 대화 화자 분리기</h1>
44
+ <p>텍스트 기반 화자 분리 도구</p>
45
+ </div>
46
+ """)
47
+
48
+ with gr.Row():
49
+ with gr.Column():
50
+ text_input = gr.Textbox(
51
+ label="2인 대화 텍스트를 입력하세요",
52
+ placeholder="두 명이 나누는 대화 내용을 여기에 입력하세요...",
53
+ lines=8
54
+ )
55
+
56
+ process_btn = gr.Button("🚀 처리 시작", variant="primary")
57
+
58
+ with gr.Column():
59
+ status_output = gr.Markdown("### 📊 처리 상태\n준비 완료.")
60
+
61
+ with gr.Tabs():
62
+ with gr.TabItem("👥 화자 분리"):
63
+ separated_output = gr.Textbox(
64
+ label="화자 분리 결과",
65
+ lines=10
66
+ )
67
+
68
+ with gr.TabItem("👤 화자1"):
69
+ speaker1_output = gr.Textbox(
70
+ label="화자1 발언",
71
+ lines=10
72
+ )
73
+
74
+ with gr.TabItem("👤 화자2"):
75
+ speaker2_output = gr.Textbox(
76
+ label="화자2 발언",
77
+ lines=10
78
+ )
79
+
80
+ process_btn.click(
81
+ fn=simple_text_separation,
82
+ inputs=[text_input],
83
+ outputs=[status_output, separated_output, speaker1_output, speaker2_output]
84
+ )
85
+
86
+ if __name__ == "__main__":
87
+ app.launch()