Spaces:
Sleeping
Sleeping
Seun commited on
Commit ·
9be2b10
1
Parent(s): 0b8ba32
yoruba asr
Browse files- app.py +29 -0
- packages.txt +1 -0
- requirements.txt +8 -0
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import whisper
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Load the Whisper model
|
| 6 |
+
model = whisper.load_model("base") # or "small", "medium", "large"
|
| 7 |
+
|
| 8 |
+
# Transcription function
|
| 9 |
+
def transcribe(audio):
|
| 10 |
+
if audio is None:
|
| 11 |
+
return "No audio received."
|
| 12 |
+
|
| 13 |
+
# Whisper expects a path to a file
|
| 14 |
+
audio_path = audio # gradio gives a temporary file path
|
| 15 |
+
result = model.transcribe(audio_path)
|
| 16 |
+
return result["text"]
|
| 17 |
+
|
| 18 |
+
# Gradio interface
|
| 19 |
+
iface = gr.Interface(
|
| 20 |
+
fn=transcribe,
|
| 21 |
+
inputs=gr.Audio(source="microphone", type="filepath", label="🎙 Record your voice"),
|
| 22 |
+
outputs="text",
|
| 23 |
+
live=False,
|
| 24 |
+
title="🗣 Whisper Transcription",
|
| 25 |
+
description="Speak for a few seconds and get the transcription using OpenAI's Whisper model."
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
# Launch the app
|
| 29 |
+
iface.launch()
|
packages.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
ffmpeg
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
torch
|
| 3 |
+
torchaudio
|
| 4 |
+
fastapi
|
| 5 |
+
uvicorn
|
| 6 |
+
pydub
|
| 7 |
+
python-multipart
|
| 8 |
+
soundfile
|