Spaces:
Runtime error
Runtime error
Jeongsoo1975
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
94d3c15
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() |