File size: 2,942 Bytes
94d3c15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import gradio as gr
import os
from datetime import datetime

def simple_text_separation(input_text):
    """간단한 텍스트 화자 분리 (API 키 없이도 작동)"""
    if not input_text.strip():
        return "❌ 텍스트를 입력해주세요.", "", ""
    
    # 간단한 분리 로직 (실제로는 AI 모델 필요)
    sentences = input_text.split('.')
    
    speaker1_lines = []
    speaker2_lines = []
    
    for i, sentence in enumerate(sentences):
        sentence = sentence.strip()
        if sentence:
            if i % 2 == 0:
                speaker1_lines.append(f"화자1: {sentence}.")
            else:
                speaker2_lines.append(f"화자2: {sentence}.")
    
    separated_text = "\n".join(speaker1_lines + speaker2_lines)
    speaker1_text = "\n".join(speaker1_lines)
    speaker2_text = "\n".join(speaker2_lines)
    
    status = f"""
✅ **처리 완료!**
- 처리 시간: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
- 화자1 발언 수: {len(speaker1_lines)}
- 화자2 발언 수: {len(speaker2_lines)}

⚠️ 현재 데모 모드입니다. AI 기반 처리를 위해서는 API 키가 필요합니다.
"""
    
    return status, separated_text, speaker1_text, speaker2_text

# Gradio 인터페이스
with gr.Blocks(title="2인 대화 화자 분리기") as app:
    gr.HTML("""
    <div style="text-align: center; margin-bottom: 20px;">
        <h1>💬 2인 대화 화자 분리기</h1>
        <p>텍스트 기반 화자 분리 도구</p>
    </div>
    """)
    
    with gr.Row():
        with gr.Column():
            text_input = gr.Textbox(
                label="2인 대화 텍스트를 입력하세요",
                placeholder="두 명이 나누는 대화 내용을 여기에 입력하세요...",
                lines=8
            )
            
            process_btn = gr.Button("🚀 처리 시작", variant="primary")
        
        with gr.Column():
            status_output = gr.Markdown("### 📊 처리 상태\n준비 완료.")
            
            with gr.Tabs():
                with gr.TabItem("👥 화자 분리"):
                    separated_output = gr.Textbox(
                        label="화자 분리 결과",
                        lines=10
                    )
                
                with gr.TabItem("👤 화자1"):
                    speaker1_output = gr.Textbox(
                        label="화자1 발언",
                        lines=10
                    )
                
                with gr.TabItem("👤 화자2"):
                    speaker2_output = gr.Textbox(
                        label="화자2 발언",
                        lines=10
                    )
    
    process_btn.click(
        fn=simple_text_separation,
        inputs=[text_input],
        outputs=[status_output, separated_output, speaker1_output, speaker2_output]
    )

if __name__ == "__main__":
    app.launch()