test_whisper / app.py
Shruti2301's picture
Update app.py
fabea19 verified
raw
history blame contribute delete
868 Bytes
import gradio as gr
from transformers import pipeline
# Use a pipeline for automatic speech recognition
asr_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-small")
# Define the transcription function
def transcribe_audio(audio_file):
# Ensure a file was uploaded
if audio_file is None:
return "Please upload an audio file."
# Transcribe the audio
transcription = asr_pipe(audio_file)["text"]
return transcription
# Create the Gradio interface
iface = gr.Interface(
fn=transcribe_audio,
inputs=gr.Audio(type="filepath", label="Upload an audio file"),
outputs="text",
title="Whisper Small ASR",
description="A public Hugging Face Space for Automatic Speech Recognition using the OpenAI Whisper Small model."
)
# This line needs to be updated to generate a public URL
iface.launch(share=True)