Spaces:
Runtime error
Runtime error
first real test
Browse files- app.py +24 -3
- requirements.txt +2 -0
app.py
CHANGED
@@ -1,7 +1,28 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
def
|
4 |
-
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import whisperx
|
3 |
+
import whisper
|
4 |
|
5 |
+
def transcribe(audio_file):
|
6 |
+
device = "cuda"
|
7 |
|
8 |
+
# Transcribe with original Whisper
|
9 |
+
model = whisper.load_model("large", device)
|
10 |
+
result = model.transcribe(audio_file)
|
11 |
+
|
12 |
+
# Load alignment model and metadata
|
13 |
+
model_a, metadata = whisperx.load_align_model(language_code=result["language"], device=device)
|
14 |
+
|
15 |
+
# Align Whisper output
|
16 |
+
result_aligned = whisperx.align(result["segments"], model_a, metadata, audio_file, device)
|
17 |
+
|
18 |
+
return result_aligned["segments"], result_aligned["word_segments"]
|
19 |
+
|
20 |
+
# Define Gradio interface
|
21 |
+
inputs = gr.inputs.Audio(source="upload", type="file")
|
22 |
+
outputs = [
|
23 |
+
gr.outputs.Textbox(label="Segments (before alignment)"),
|
24 |
+
gr.outputs.Textbox(label="Segments (after alignment)"),
|
25 |
+
]
|
26 |
+
|
27 |
+
iface = gr.Interface(fn=transcribe, inputs=inputs, outputs=outputs, title="WhisperX Transcription")
|
28 |
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
git+https://github.com/m-bain/whisperx.git
|