Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,27 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from pyannote.audio import Pipeline
|
3 |
|
4 |
+
# Load the diarization pipeline
|
5 |
+
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")
|
6 |
+
|
7 |
+
# Function to handle diarization
|
8 |
+
def diarize_audio(file_path):
|
9 |
+
diarization = pipeline(file_path)
|
10 |
+
|
11 |
+
# Create a result to show the speaker segments
|
12 |
+
result = []
|
13 |
+
for segment, _, speaker in diarization.itertracks(yield_label=True):
|
14 |
+
result.append(f"Speaker {speaker}: from {segment.start:.1f} to {segment.end:.1f}")
|
15 |
+
return "\n".join(result)
|
16 |
+
|
17 |
+
# Create Gradio interface
|
18 |
+
interface = gr.Interface(
|
19 |
+
fn=diarize_audio,
|
20 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
21 |
+
outputs="text",
|
22 |
+
title="Speaker Diarization",
|
23 |
+
description="Upload an audio file to perform speaker diarization."
|
24 |
+
)
|
25 |
+
|
26 |
+
# Launch the Gradio app
|
27 |
+
interface.launch()
|