Spaces:
Running
on
Zero
Running
on
Zero
devingulliver
commited on
First draft
Browse files
app.py
CHANGED
@@ -1,13 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
import torch
|
|
|
|
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
|
8 |
@spaces.GPU
|
9 |
-
def
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
gr.Interface(fn=greet, inputs=gr.
|
|
|
1 |
import gradio as gr
|
2 |
import spaces
|
3 |
import torch
|
4 |
+
from transformers.pipelines.audio_utils import ffmpeg_read
|
5 |
+
import io
|
6 |
+
import whisper
|
7 |
|
8 |
+
model = whisper.load_model("large", device="cuda")
|
9 |
+
writer = whisper.utils.get_writer("srt", "/dev/null")
|
10 |
|
11 |
@spaces.GPU
|
12 |
+
def generate(file):
|
13 |
+
# get file to type bytes somehow
|
14 |
+
audio = ffmpeg_read(file)
|
15 |
+
result = model.transcribe(audio)
|
16 |
+
out = io.StringIO()
|
17 |
+
writer.write_result(result, out)
|
18 |
+
return out.getvalue()
|
19 |
|
20 |
+
gr.Interface(fn=greet, inputs=gr.File(type="binary"), outputs=gr.Text()).launch()
|