Nitzantry1 commited on
Commit
8640564
ยท
verified ยท
1 Parent(s): d9e71ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -20,22 +20,17 @@ except Exception as e:
20
  # ืคื•ื ืงืฆื™ื” ืœื–ื™ื”ื•ื™ ื“ื•ื‘ืจื™ื
21
  def diarize(audio):
22
  try:
23
- # ืฉืžื™ืจืช ื”ืื•ื“ื™ื• ืœืงื•ื‘ืฅ ื–ืžื ื™
24
- with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_audio:
25
- temp_audio.write(audio.read())
26
- temp_audio_path = temp_audio.name
27
 
28
  # ืขื™ื‘ื•ื“ ื”ืื•ื“ื™ื• ืขื pyannote
29
- diarization = pipeline(temp_audio_path)
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: