transcribeapi / app.py
peterkros's picture
Update app.py
9e71ecb verified
raw
history blame
740 Bytes
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()