Nitzantry1
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,24 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from pyannote.audio import Pipeline
|
3 |
|
4 |
+
# ืืืขื ืืช ืืืืื ืฉื pyannote
|
5 |
+
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")
|
6 |
+
|
7 |
+
# ืคืื ืงืฆืื ืืขืืืื ืงืืืฅ ืืืืื
|
8 |
+
def diarize_audio(audio_path):
|
9 |
+
diarization = pipeline(audio_path)
|
10 |
+
results = []
|
11 |
+
for turn, _, speaker in diarization.itertracks(yield_label=True):
|
12 |
+
results.append(f"{turn.start:.1f}s - {turn.end:.1f}s: {speaker}")
|
13 |
+
return "\n".join(results)
|
14 |
+
|
15 |
+
# ืืืืจืช ืืืฉืง Gradio
|
16 |
+
interface = gr.Interface(
|
17 |
+
fn=diarize_audio,
|
18 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
19 |
+
outputs="text",
|
20 |
+
title="Speaker Diarization"
|
21 |
+
)
|
22 |
+
|
23 |
+
# ืืจืฆืช ืืืคืืืงืฆืื
|
24 |
+
interface.launch()
|