Spaces:
Running
on
Zero
Running
on
Zero
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") | |
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() |