Sharfraz's picture
Update app.py
54a802f verified
raw
history blame contribute delete
851 Bytes
import gradio as gr
from transformers import WhisperProcessor, FlaxWhisperForConditionalGeneration
from transformers import pipeline
whisper_model = pipeline("automatic-speech-recognition", model="openai/whisper-small")
def transcribe(audio):
# Preprocess audio
inputs = processor(audio, return_tensors="np", sampling_rate=16000)
input_features = inputs.input_features
# Generate transcription
predicted_ids = model.generate(input_features)
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
return transcription
# Gradio Interface
interface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="upload", type="numpy"),
outputs="text",
title="Whisper JAX Transcription",
description="Upload an audio file to transcribe using Whisper JAX."
)
interface.launch()