Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,19 @@
|
|
| 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")
|
| 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 =
|
| 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="
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
| 3 |
import torch
|
|
|
|
| 4 |
import io
|
| 5 |
import whisper
|
| 6 |
|
| 7 |
+
model = whisper.load_model("large", device="cpu")
|
| 8 |
writer = whisper.utils.get_writer("srt", "/dev/null")
|
| 9 |
|
| 10 |
@spaces.GPU
|
| 11 |
def generate(file):
|
| 12 |
# get file to type bytes somehow
|
| 13 |
+
audio = whisper.load_audio(file)
|
| 14 |
result = model.transcribe(audio)
|
| 15 |
out = io.StringIO()
|
| 16 |
writer.write_result(result, out)
|
| 17 |
return out.getvalue()
|
| 18 |
|
| 19 |
+
gr.Interface(fn=greet, inputs=gr.File(type="filepath"), outputs=gr.Text()).launch()
|