Spaces:
Sleeping
Sleeping
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() | |