Spaces:
Sleeping
Sleeping
Inital commit
Browse files- app.py +23 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
|
| 5 |
+
# Load the Whisper pipeline
|
| 6 |
+
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base") # Choose your Whisper size
|
| 7 |
+
|
| 8 |
+
def transcribe_audio(audio_file):
|
| 9 |
+
if audio_file is not None:
|
| 10 |
+
text = transcriber(audio_file)["text"]
|
| 11 |
+
return text
|
| 12 |
+
else:
|
| 13 |
+
return "No audio file uploaded"
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
with gr.Blocks() as demo:
|
| 17 |
+
gr.Markdown("## Audio Transcription with Whisper")
|
| 18 |
+
audio_input = gr.Audio(source="upload", type="filepath", label="Upload Audio File")
|
| 19 |
+
text_output = gr.Textbox(label="Transcription")
|
| 20 |
+
btn = gr.Button("Transcribe")
|
| 21 |
+
btn.click(transcribe_audio, inputs=audio_input, outputs=text_output)
|
| 22 |
+
|
| 23 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
transformers
|
| 2 |
+
gradio
|
| 3 |
+
torch
|