Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load ASR pipeline
|
| 5 |
+
asr_pipeline = pipeline(task="automatic-speech-recognition", model="openai/whisper-small")
|
| 6 |
+
# 🔹 Replace with your own model if you trained one, e.g., "Devion333/whisper-small-dv-syn"
|
| 7 |
+
|
| 8 |
+
def transcribe(audio):
|
| 9 |
+
result = asr_pipeline(audio)
|
| 10 |
+
return result["text"]
|
| 11 |
+
|
| 12 |
+
# Build Gradio app
|
| 13 |
+
gradio_app = gr.Interface(
|
| 14 |
+
fn=transcribe,
|
| 15 |
+
inputs=gr.Audio(sources=["upload", "microphone"], type="filepath", label="Speak or Upload Audio"),
|
| 16 |
+
outputs=gr.Textbox(label="Transcription"),
|
| 17 |
+
title="Speech-to-Text (ASR)",
|
| 18 |
+
description="Upload an audio file or record speech and get the transcription using a Hugging Face ASR model."
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
if __name__ == "__main__":
|
| 22 |
+
gradio_app.launch()
|