Nitzantry1 commited on
Commit
9cba922
ยท
verified ยท
1 Parent(s): c09680d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,3 +1,24 @@
1
  import gradio as gr
 
2
 
3
- gr.load("models/pyannote/speaker-diarization").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()