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