Spaces:
Runtime error
Runtime error
Update main.py
Browse files
main.py
CHANGED
|
@@ -8,11 +8,15 @@ whisper = pipeline("automatic-speech-recognition", model="openai/whisper-base")
|
|
| 8 |
|
| 9 |
# ์์ฑ์ ํ
์คํธ๋ก ๋ณํํ๋ ํจ์
|
| 10 |
def transcribe_audio(audio):
|
|
|
|
|
|
|
|
|
|
| 11 |
result = whisper(audio)
|
| 12 |
return result["text"], base64.b64encode(result["text"].encode()).decode() #type: ignore
|
| 13 |
|
| 14 |
# Gradio ์ธํฐํ์ด์ค
|
| 15 |
-
demo = gr.Interface(
|
|
|
|
| 16 |
inputs=gr.Audio(label = '์ค๋์ค', sources="microphone", type='numpy'),
|
| 17 |
outputs=[gr.Textbox(label='๊ฒฐ๊ณผ'), gr.Textbox(label='์ํธํ๋ ๊ฒฐ๊ณผ')],
|
| 18 |
title='์ด์ฐ์ง์ Speech to Text',
|
|
|
|
| 8 |
|
| 9 |
# ์์ฑ์ ํ
์คํธ๋ก ๋ณํํ๋ ํจ์
|
| 10 |
def transcribe_audio(audio):
|
| 11 |
+
if audio is None:
|
| 12 |
+
return "No audio detected. Please try recording again.", ""
|
| 13 |
+
|
| 14 |
result = whisper(audio)
|
| 15 |
return result["text"], base64.b64encode(result["text"].encode()).decode() #type: ignore
|
| 16 |
|
| 17 |
# Gradio ์ธํฐํ์ด์ค
|
| 18 |
+
demo = gr.Interface(
|
| 19 |
+
fn=transcribe_audio,
|
| 20 |
inputs=gr.Audio(label = '์ค๋์ค', sources="microphone", type='numpy'),
|
| 21 |
outputs=[gr.Textbox(label='๊ฒฐ๊ณผ'), gr.Textbox(label='์ํธํ๋ ๊ฒฐ๊ณผ')],
|
| 22 |
title='์ด์ฐ์ง์ Speech to Text',
|