Spaces:
Running
on
Zero
Running
on
Zero
File size: 715 Bytes
93ec611 9f1070e 9f13a48 e846051 03b7abb 44800c6 93ec611 9f1070e 93ec611 44800c6 19001c8 9f1070e 00b55b7 e460592 19001c8 9f1070e 93ec611 62e3412 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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() |