File size: 1,477 Bytes
129bd00
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
import whisper

# Load the Whisper model 
model = whisper.load_model("base")

# Define the waiter prompt in Korean.
prompt_text = """
안녕하세요, 손님!
오늘 저희 레스토랑에 방문해 주셔서 감사합니다.
저는 여러분의 웨이터입니다.
메뉴를 보시고 주문하실 음식을 결정해 주세요.
예시: "불고기와 콩나물국, 그리고 식혜 하나 부탁드립니다."
준비되셨다면, 아래의 녹음 버튼을 눌러 주문 내용을 말씀해 주세요.
"""

def process_audio(audio_file):
    if audio_file is None:
        return "오디오 파일이 없습니다. 다시 시도해 주세요."
    
    result = model.transcribe(audio_file, language='ko')
    transcription = result["text"].strip()
    return transcription

with gr.Blocks() as demo:
    gr.Markdown("## 한국어 주문 녹음 앱")
    
    # Embed the animated GIF for the waiter animation.
    gr.Image(value="https://s13.gifyu.com/images/b2NQh.gif", label="웨이터 안내 애니메이션")
    
    gr.Markdown(prompt_text)
    
    # Removed the "source" argument
    audio_input = gr.Audio(type="filepath", label="녹음: 주문 내용을 말씀해 주세요")
    submit_btn = gr.Button("전송")
    transcription_output = gr.Textbox(label="주문 녹취 결과", placeholder="여기에 전사 결과가 나타납니다.")
    
    submit_btn.click(process_audio, inputs=audio_input, outputs=transcription_output)

demo.launch()