Spaces:
Runtime error
Runtime error
V1
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
# Load Whisper pipeline
|
| 4 |
+
pipe = pipeline(task="automatic-speech-recognition", model="openai/whisper-small")
|
| 5 |
+
# Function to transcribe audio file
|
| 6 |
+
def transcribe(audio_file):
|
| 7 |
+
if audio_file is None:
|
| 8 |
+
return "Please upload an audio file."
|
| 9 |
+
return pipe(audio_file)["text"]
|
| 10 |
+
# Gradio Interface
|
| 11 |
+
with gr.Blocks() as app:
|
| 12 |
+
gr.Markdown("## 🎙 Whisper Speech-to-Text (ASR)\nUpload or record audio and get transcription.")
|
| 13 |
+
|
| 14 |
+
with gr.Row():
|
| 15 |
+
audio_input = gr.Audio(type="filepath", label="Upload or Record Audio")
|
| 16 |
+
output_text = gr.Textbox(label="Transcription")
|
| 17 |
+
|
| 18 |
+
transcribe_btn = gr.Button("Transcribe")
|
| 19 |
+
transcribe_btn.click(fn=transcribe, inputs=audio_input, outputs=output_text)
|
| 20 |
+
app.launch()
|