Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load your model from the Hub
|
| 5 |
+
pipe = pipeline("automatic-speech-recognition", model="uzair0/Katib-ASR")
|
| 6 |
+
|
| 7 |
+
def transcribe_audio(audio_filepath):
|
| 8 |
+
if audio_filepath is None:
|
| 9 |
+
return "⚠️ Please record some audio first!"
|
| 10 |
+
result = pipe(
|
| 11 |
+
audio_filepath,
|
| 12 |
+
generate_kwargs={"language": "pashto", "task": "transcribe"}
|
| 13 |
+
)
|
| 14 |
+
return result["text"]
|
| 15 |
+
|
| 16 |
+
demo = gr.Interface(
|
| 17 |
+
fn=transcribe_audio,
|
| 18 |
+
inputs=gr.Audio(sources=["microphone"], type="filepath", label="Record Pashto"),
|
| 19 |
+
outputs=gr.Textbox(label="Katib ASR Transcription", lines=3),
|
| 20 |
+
title="🎙️ Katib ASR: Pashto Speech Recognition",
|
| 21 |
+
description="Click the Record button below, speak Pashto into your microphone, and see the result!"
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
demo.launch()
|