Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import whisper
|
| 3 |
|
| 4 |
-
# Load the Whisper model
|
| 5 |
model = whisper.load_model("base")
|
| 6 |
|
| 7 |
# Define the waiter prompt in Korean.
|
|
@@ -17,24 +17,48 @@ prompt_text = """
|
|
| 17 |
def process_audio(audio_file):
|
| 18 |
if audio_file is None:
|
| 19 |
return "오디오 파일이 없습니다. 다시 시도해 주세요."
|
| 20 |
-
|
| 21 |
result = model.transcribe(audio_file, language='ko')
|
| 22 |
transcription = result["text"].strip()
|
| 23 |
return transcription
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
with gr.Blocks() as demo:
|
| 26 |
gr.Markdown("## 한국어 주문 녹음 앱")
|
| 27 |
-
|
| 28 |
# Embed the animated GIF for the waiter animation.
|
| 29 |
gr.Image(value="https://s13.gifyu.com/images/b2NQh.gif", label="웨이터 안내 애니메이션")
|
| 30 |
-
|
| 31 |
gr.Markdown(prompt_text)
|
| 32 |
-
|
| 33 |
-
#
|
| 34 |
audio_input = gr.Audio(type="filepath", label="녹음: 주문 내용을 말씀해 주세요")
|
| 35 |
-
|
|
|
|
| 36 |
transcription_output = gr.Textbox(label="주문 녹취 결과", placeholder="여기에 전사 결과가 나타납니다.")
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
submit_btn.click(process_audio, inputs=audio_input, outputs=transcription_output)
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import whisper
|
| 3 |
|
| 4 |
+
# Load the Whisper model
|
| 5 |
model = whisper.load_model("base")
|
| 6 |
|
| 7 |
# Define the waiter prompt in Korean.
|
|
|
|
| 17 |
def process_audio(audio_file):
|
| 18 |
if audio_file is None:
|
| 19 |
return "오디오 파일이 없습니다. 다시 시도해 주세요."
|
| 20 |
+
|
| 21 |
result = model.transcribe(audio_file, language='ko')
|
| 22 |
transcription = result["text"].strip()
|
| 23 |
return transcription
|
| 24 |
|
| 25 |
+
def evaluate_transcription(transcription):
|
| 26 |
+
if transcription is None or transcription.strip() == "":
|
| 27 |
+
return "입력된 내용이 없습니다."
|
| 28 |
+
|
| 29 |
+
# Simulated GPT evaluation response.
|
| 30 |
+
dummy_response = (
|
| 31 |
+
"GPT 평가 결과:\n"
|
| 32 |
+
"주문 내용이 전반적으로 명확합니다. "
|
| 33 |
+
"더 구체적인 요청이나 추가 정보가 있으면 좋겠지만, 현재 주문은 잘 전달된 것 같습니다."
|
| 34 |
+
)
|
| 35 |
+
return dummy_response
|
| 36 |
+
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
gr.Markdown("## 한국어 주문 녹음 앱")
|
| 39 |
+
|
| 40 |
# Embed the animated GIF for the waiter animation.
|
| 41 |
gr.Image(value="https://s13.gifyu.com/images/b2NQh.gif", label="웨이터 안내 애니메이션")
|
| 42 |
+
|
| 43 |
gr.Markdown(prompt_text)
|
| 44 |
+
|
| 45 |
+
# Audio input (without source parameter)
|
| 46 |
audio_input = gr.Audio(type="filepath", label="녹음: 주문 내용을 말씀해 주세요")
|
| 47 |
+
|
| 48 |
+
# Transcription output
|
| 49 |
transcription_output = gr.Textbox(label="주문 녹취 결과", placeholder="여기에 전사 결과가 나타납니다.")
|
| 50 |
+
|
| 51 |
+
# Evaluation output (simulated GPT feedback)
|
| 52 |
+
evaluation_output = gr.Textbox(label="GPT 평가 결과", placeholder="여기에 평가 결과가 나타납니다.")
|
| 53 |
+
|
| 54 |
+
# Buttons
|
| 55 |
+
submit_btn = gr.Button("전송")
|
| 56 |
+
evaluate_btn = gr.Button("평가")
|
| 57 |
+
|
| 58 |
+
# When clicking "전송", process the audio and display the transcription.
|
| 59 |
submit_btn.click(process_audio, inputs=audio_input, outputs=transcription_output)
|
| 60 |
|
| 61 |
+
# When clicking "평가", simulate GPT's evaluation.
|
| 62 |
+
evaluate_btn.click(evaluate_transcription, inputs=transcription_output, outputs=evaluation_output)
|
| 63 |
+
|
| 64 |
+
demo.launch()
|