import torch | |
from transformers import pipeline | |
import gradio as gr | |
MODEL_NAME = "Shamik/distil-whisper-small-polyAI-minds14" | |
pipe = pipeline( | |
task="automatic-speech-recognition", | |
model=MODEL_NAME, | |
chunk_length_s=30, | |
) | |
def transcribe(file): | |
outputs = pipe(file) | |
text = outputs["text"] | |
return text | |
demo = gr.Interface( | |
fn=transcribe, | |
inputs=[ | |
gr.Audio(sources="upload", label="Audio file", type="filepath"), | |
], | |
outputs="text", | |
title="Distil Whisper English Speech Transcription", | |
description=( | |
"Transcribe long-form audio inputs with the click of a button! Demo uses the" | |
f" checkpoint [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to transcribe audio files" | |
" of arbitrary length." | |
), | |
examples=[ | |
["./example2.flac"], | |
["./example0.flac"], | |
], | |
cache_examples=True, | |
allow_flagging="never", | |
) | |
demo.launch() |