import gradio as gr import base64 import torch from transformers import pipeline # Whisper 모델을 pipeline으로 불러오기 whisper = pipeline("automatic-speech-recognition", model="openai/whisper-small") # 음성을 텍스트로 변환하는 함수 def transcribe_audio(audio): if audio is None: return "에러: 오디오 없음", "" result = whisper(audio) return result["text"], base64.b64encode(result["text"].encode()).decode() # Gradio 인터페이스 demo = gr.Interface( fn=transcribe_audio, inputs=gr.Audio(label = '오디오', sources="microphone", type='filepath'), outputs=[gr.Textbox(label='결과'), gr.Textbox(label='암호화된 결과')], title='이우진의 Speech to Text (※ 녹음 후 바로 실행 누르면 에러남)', description='기여도: AI 60% 나 40%', submit_btn='실행', clear_btn='지우기') # 앱 실행 demo.launch()