Nitzantry1 commited on
Commit
e58bff7
ยท
verified ยท
1 Parent(s): d75df76

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pyannote.audio import Pipeline
2
+ import gradio as gr
3
+ import os
4
+
5
+ # ืฉืœื™ืคืช ื”-Token ืžื”-Secret
6
+ hf_token = os.getenv("HF_TOKEN")
7
+
8
+ # ื˜ืขื™ื ืช ื”ืžื•ื“ืœ ืขื ื”-Token
9
+ pipeline = Pipeline.from_pretrained(
10
+ "pyannote/speaker-diarization",
11
+ use_auth_token=hf_token
12
+ )
13
+
14
+ # ืคื•ื ืงืฆื™ื” ืœื–ื™ื”ื•ื™ ื“ื•ื‘ืจื™ื
15
+ def diarize(audio):
16
+ diarization = pipeline(audio)
17
+ result = []
18
+ for turn, _, speaker in diarization.itertracks(yield_label=True):
19
+ result.append(f"{speaker}: {turn.start:.1f}s - {turn.end:.1f}s")
20
+ return "\n".join(result)
21
+
22
+ # ืžืžืฉืง ืžืฉืชืžืฉ ืขื Gradio
23
+ interface = gr.Interface(
24
+ fn=diarize,
25
+ inputs="audio",
26
+ outputs="text",
27
+ title="Speaker Diarization",
28
+ description="Upload an audio file to detect speakers and their timestamps."
29
+ )
30
+
31
+ interface.launch()