whisper-zero / app.py
devingulliver's picture
switch back to distil large v3
44800c6 verified
raw
history blame contribute delete
715 Bytes
import gradio as gr
import spaces
import torch
import io
import whisper
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(repo_id="distil-whisper/distil-large-v3-openai", filename="model.bin")
writer = whisper.utils.get_writer("srt", "/dev/null")
@spaces.GPU(duration=90)
def generate(file, progress=gr.Progress(track_tqdm=True)):
# get file to type bytes somehow
model = whisper.load_model(model_path, device="cuda")
audio = whisper.load_audio(file)
result = model.transcribe(audio, verbose=False)
out = io.StringIO()
writer.write_result(result, out)
return out.getvalue()
gr.Interface(fn=generate, inputs=gr.File(type="filepath"), outputs=gr.Text()).launch()