Upload 2 files
Browse files- app (1).py +21 -0
- requirements.txt +3 -0
app (1).py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
# Load the model
|
| 6 |
+
asr = pipeline("automatic-speech-recognition", model="Abdallahsadek/speech-to-text-model2")
|
| 7 |
+
|
| 8 |
+
# Transcription function
|
| 9 |
+
def transcribe(audio):
|
| 10 |
+
return asr(audio)["text"]
|
| 11 |
+
|
| 12 |
+
# Gradio interface
|
| 13 |
+
interface = gr.Interface(
|
| 14 |
+
fn=transcribe,
|
| 15 |
+
inputs=gr.Audio(sources=["microphone", "upload"], type="filepath"),
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="🎙️ Speech-to-Text",
|
| 18 |
+
description="Speak or upload an audio file to transcribe it using Hugging Face model.",
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
interface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torchaudio
|