Spaces:
Runtime error
Runtime error
Jeongsoo1975
commited on
Commit
·
d76d4c0
1
Parent(s):
ad0eadb
fix: 오디오 업로드 UI가 표시되지 않는 문제 수정
Browse files- app.py +4 -20
- requirements.txt +0 -2
app.py
CHANGED
|
@@ -1,10 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import logging
|
| 4 |
-
import tempfile
|
| 5 |
-
import whisper
|
| 6 |
from datetime import datetime
|
| 7 |
-
from stt_processor import TextProcessor
|
| 8 |
|
| 9 |
# 로깅 설정
|
| 10 |
logging.basicConfig(
|
|
@@ -30,12 +27,14 @@ def initialize_models():
|
|
| 30 |
if not google_api_key:
|
| 31 |
return False, "❌ Google API 키가 설정되지 않았습니다. Hugging Face Spaces의 Settings에서 GOOGLE_API_KEY를 설정해주세요."
|
| 32 |
|
| 33 |
-
# Whisper 모델 로드
|
|
|
|
| 34 |
logger.info("Whisper 모델을 로딩합니다...")
|
| 35 |
whisper_model = whisper.load_model("base")
|
| 36 |
logger.info("Whisper 모델 로딩 완료")
|
| 37 |
|
| 38 |
# 텍스트 프로세서 초기화
|
|
|
|
| 39 |
text_processor = TextProcessor(google_api_key)
|
| 40 |
return True, "✅ 모든 모델이 초기화되었습니다."
|
| 41 |
|
|
@@ -46,13 +45,6 @@ def initialize_models():
|
|
| 46 |
def process_audio_file(audio_file, progress=gr.Progress()):
|
| 47 |
"""
|
| 48 |
업로드된 오디오 파일을 처리합니다.
|
| 49 |
-
|
| 50 |
-
Args:
|
| 51 |
-
audio_file: 업로드된 오디오 파일
|
| 52 |
-
progress: Gradio 진행률 객체
|
| 53 |
-
|
| 54 |
-
Returns:
|
| 55 |
-
tuple: (처리 상태, 원본 텍스트, 화자 분리 결과, 교정 결과, 화자1 대화, 화자2 대화)
|
| 56 |
"""
|
| 57 |
global text_processor, whisper_model
|
| 58 |
|
|
@@ -133,13 +125,6 @@ def process_audio_file(audio_file, progress=gr.Progress()):
|
|
| 133 |
def process_text_input(input_text, progress=gr.Progress()):
|
| 134 |
"""
|
| 135 |
입력된 텍스트를 처리합니다.
|
| 136 |
-
|
| 137 |
-
Args:
|
| 138 |
-
input_text: 처리할 텍스트
|
| 139 |
-
progress: Gradio 진행률 객체
|
| 140 |
-
|
| 141 |
-
Returns:
|
| 142 |
-
tuple: (처리 상태, 원본 텍스트, 화자 분리 결과, 교정 결과, 화자1 대화, 화자2 대화)
|
| 143 |
"""
|
| 144 |
global text_processor
|
| 145 |
|
|
@@ -236,8 +221,7 @@ def create_interface():
|
|
| 236 |
gr.Markdown("### 🎤 오디오 파일 업로드")
|
| 237 |
audio_input = gr.Audio(
|
| 238 |
label="2인 대화 오디오 파일을 업로드하세요",
|
| 239 |
-
type="filepath"
|
| 240 |
-
format="wav"
|
| 241 |
)
|
| 242 |
audio_process_btn = gr.Button(
|
| 243 |
"🚀 오디오 처리 시작",
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import logging
|
|
|
|
|
|
|
| 4 |
from datetime import datetime
|
|
|
|
| 5 |
|
| 6 |
# 로깅 설정
|
| 7 |
logging.basicConfig(
|
|
|
|
| 27 |
if not google_api_key:
|
| 28 |
return False, "❌ Google API 키가 설정되지 않았습니다. Hugging Face Spaces의 Settings에서 GOOGLE_API_KEY를 설정해주세요."
|
| 29 |
|
| 30 |
+
# Whisper 모델 로드 (지연 로딩)
|
| 31 |
+
import whisper
|
| 32 |
logger.info("Whisper 모델을 로딩합니다...")
|
| 33 |
whisper_model = whisper.load_model("base")
|
| 34 |
logger.info("Whisper 모델 로딩 완료")
|
| 35 |
|
| 36 |
# 텍스트 프로세서 초기화
|
| 37 |
+
from stt_processor import TextProcessor
|
| 38 |
text_processor = TextProcessor(google_api_key)
|
| 39 |
return True, "✅ 모든 모델이 초기화되었습니다."
|
| 40 |
|
|
|
|
| 45 |
def process_audio_file(audio_file, progress=gr.Progress()):
|
| 46 |
"""
|
| 47 |
업로드된 오디오 파일을 처리합니다.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
"""
|
| 49 |
global text_processor, whisper_model
|
| 50 |
|
|
|
|
| 125 |
def process_text_input(input_text, progress=gr.Progress()):
|
| 126 |
"""
|
| 127 |
입력된 텍스트를 처리합니다.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
"""
|
| 129 |
global text_processor
|
| 130 |
|
|
|
|
| 221 |
gr.Markdown("### 🎤 오디오 파일 업로드")
|
| 222 |
audio_input = gr.Audio(
|
| 223 |
label="2인 대화 오디오 파일을 업로드하세요",
|
| 224 |
+
type="filepath"
|
|
|
|
| 225 |
)
|
| 226 |
audio_process_btn = gr.Button(
|
| 227 |
"🚀 오디오 처리 시작",
|
requirements.txt
CHANGED
|
@@ -2,5 +2,3 @@ python-dotenv==1.0.0
|
|
| 2 |
google-generativeai==0.8.3
|
| 3 |
gradio==4.44.0
|
| 4 |
openai-whisper==20240930
|
| 5 |
-
torch==2.0.1
|
| 6 |
-
torchaudio==2.0.2
|
|
|
|
| 2 |
google-generativeai==0.8.3
|
| 3 |
gradio==4.44.0
|
| 4 |
openai-whisper==20240930
|
|
|
|
|
|