Spaces:
Sleeping
Sleeping
File size: 543 Bytes
93ec611 9f1070e 93ec611 9f1070e 93ec611 9f1070e 93ec611 9f1070e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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() |