File size: 851 Bytes
5625178
 
 
54a802f
 
5625178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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()