Spaces:
Build error
Build error
Commit ·
736facd
1
Parent(s): b822fe5
Add main Whisper logic
Browse files
app.py
CHANGED
|
@@ -1,8 +1,21 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from faster_whisper import WhisperModel
|
| 3 |
|
| 4 |
+
model = WhisperModel("large-v3", device="cuda", compute_type="float16")
|
|
|
|
| 5 |
|
| 6 |
+
def transcribe(audio_path, task):
|
| 7 |
+
segments, _ = model.transcribe(audio_path, beam_size=5, language="en")
|
| 8 |
+
return "\n".join([seg.text for seg in segments])
|
| 9 |
+
|
| 10 |
+
iface = gr.Interface(
|
| 11 |
+
fn=transcribe,
|
| 12 |
+
inputs=[
|
| 13 |
+
gr.Audio(source="upload", type="filepath", label="Upload audio"),
|
| 14 |
+
gr.Radio(["transcribe", "translate"], label="Task", value="transcribe")
|
| 15 |
+
],
|
| 16 |
+
outputs="text",
|
| 17 |
+
title="Fast Whisper Transcription"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.queue().launch()
|
| 21 |
|