Spaces:
Running
on
Zero
Running
on
Zero
import gradio as gr | |
import spaces | |
import torch | |
from transformers.pipelines.audio_utils import ffmpeg_read | |
import io | |
import whisper | |
model = whisper.load_model("large", device="cuda") | |
writer = whisper.utils.get_writer("srt", "/dev/null") | |
def generate(file): | |
# get file to type bytes somehow | |
audio = ffmpeg_read(file) | |
result = model.transcribe(audio) | |
out = io.StringIO() | |
writer.write_result(result, out) | |
return out.getvalue() | |
gr.Interface(fn=greet, inputs=gr.File(type="binary"), outputs=gr.Text()).launch() |