whisper-zero / app.py
devingulliver's picture
First draft
9f1070e verified
raw
history blame
543 Bytes
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")
@spaces.GPU
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()