File size: 740 Bytes
f345224
dd6327f
d222613
dd6327f
 
 
d222613
f345224
d222613
dd6327f
 
f345224
 
 
 
9e71ecb
f345224
 
dd6327f
f345224
d222613
f345224
dd6327f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import gradio as gr
from transformers import pipeline

# Load Whisper model from Hugging Face
# This uses the `transformers` library's pipeline to load the model
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-large-v3")

def transcribe(audio):
    # Transcribe the audio using the Whisper model
    result = transcriber(audio)["text"]
    return result

# Create a Gradio Interface
interface = gr.Interface(
    fn=transcribe, 
    inputs=gr.Audio(sources="upload", type="filepath"), 
    outputs="text",
    title="Whisper Speech-to-Text API",
    description="Upload an audio file and get a transcription using OpenAI's Whisper model from Hugging Face."
)

# Launch the interface as an API
interface.launch()