Update app.py
Browse files
app.py
CHANGED
|
@@ -6,22 +6,19 @@ model = whisper.load_model("large-v3")
|
|
| 6 |
|
| 7 |
def transcribe(audio):
|
| 8 |
"""Transcribes the given audio file."""
|
| 9 |
-
|
| 10 |
-
|
|
|
|
| 11 |
return result["text"]
|
| 12 |
|
| 13 |
-
with gr.Blocks(
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
output_text = gr.Textbox(label="Transcription")
|
| 23 |
-
transcribe_button = gr.Button("Transcribe")
|
| 24 |
-
|
| 25 |
-
transcribe_button.click(fn=transcribe, inputs=audio_input, outputs=output_text)
|
| 26 |
|
| 27 |
demo.launch()
|
|
|
|
| 6 |
|
| 7 |
def transcribe(audio):
|
| 8 |
"""Transcribes the given audio file."""
|
| 9 |
+
if audio is None:
|
| 10 |
+
return "Please upload an audio file."
|
| 11 |
+
result = model.transcribe(audio)
|
| 12 |
return result["text"]
|
| 13 |
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
gr.Markdown("# Audio Transcription")
|
| 16 |
+
gr.Markdown("This demo uses the OpenAI Whisper-large-v3 model for audio transcription.")
|
| 17 |
+
|
| 18 |
+
audio_input = gr.Audio(type="filepath") # Corrected
|
| 19 |
+
transcribe_button = gr.Button("Transcribe")
|
| 20 |
+
output_text = gr.Textbox(label="Transcription")
|
| 21 |
+
|
| 22 |
+
transcribe_button.click(fn=transcribe, inputs=audio_input, outputs=output_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
demo.launch()
|