Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -20,22 +20,17 @@ except Exception as e:
|
|
20 |
# ืคืื ืงืฆืื ืืืืืื ืืืืจืื
|
21 |
def diarize(audio):
|
22 |
try:
|
23 |
-
#
|
24 |
-
|
25 |
-
temp_audio.write(audio.read())
|
26 |
-
temp_audio_path = temp_audio.name
|
27 |
|
28 |
# ืขืืืื ืืืืืื ืขื pyannote
|
29 |
-
diarization = pipeline(
|
30 |
|
31 |
# ืขืืืื ืืชืืฆืื ืืืืืื ืืืืจืื
|
32 |
result = []
|
33 |
for turn, _, speaker in diarization.itertracks(yield_label=True):
|
34 |
result.append(f"{speaker}: {turn.start:.1f}s - {turn.end:.1f}s")
|
35 |
|
36 |
-
# ืืืืงืช ืงืืืฅ ืืื ื ืืืืจ ืฉืืืืฉ
|
37 |
-
os.remove(temp_audio_path)
|
38 |
-
|
39 |
return "\n".join(result)
|
40 |
|
41 |
except Exception as e:
|
|
|
20 |
# ืคืื ืงืฆืื ืืืืืื ืืืืจืื
|
21 |
def diarize(audio):
|
22 |
try:
|
23 |
+
# Gradio ืฉืืื tuple ืืคืืจืื (ื ืชืื ืงืืืฅ, sample_rate)
|
24 |
+
audio_file_path = audio[0]
|
|
|
|
|
25 |
|
26 |
# ืขืืืื ืืืืืื ืขื pyannote
|
27 |
+
diarization = pipeline(audio_file_path)
|
28 |
|
29 |
# ืขืืืื ืืชืืฆืื ืืืืืื ืืืืจืื
|
30 |
result = []
|
31 |
for turn, _, speaker in diarization.itertracks(yield_label=True):
|
32 |
result.append(f"{speaker}: {turn.start:.1f}s - {turn.end:.1f}s")
|
33 |
|
|
|
|
|
|
|
34 |
return "\n".join(result)
|
35 |
|
36 |
except Exception as e:
|