Jedi09 commited on
Commit
bf646a8
·
verified ·
1 Parent(s): fee9974

Update diarization.py

Browse files
Files changed (1) hide show
  1. diarization.py +10 -3
diarization.py CHANGED
@@ -67,10 +67,14 @@ def diarize_audio(audio_path: str, pipeline, num_speakers: int = None) -> List[T
67
  return []
68
 
69
  try:
70
- # Run diarization (auto-detect speakers or use specified count)
 
 
71
  if num_speakers:
72
- result = pipeline(audio_path, min_speakers=1, max_speakers=num_speakers)
 
73
  else:
 
74
  result = pipeline(audio_path)
75
 
76
  # Extract segments from DiarizeOutput object
@@ -84,10 +88,13 @@ def diarize_audio(audio_path: str, pipeline, num_speakers: int = None) -> List[T
84
  diarization = result
85
 
86
  # Now iterate over the Annotation object
 
87
  for segment, track, speaker in diarization.itertracks(yield_label=True):
88
  segments.append((segment.start, segment.end, speaker))
 
89
 
90
- print(f"✅ Diarization tamamlandı: {len(segments)} segment bulundu")
 
91
  return segments
92
 
93
  except Exception as e:
 
67
  return []
68
 
69
  try:
70
+ # Run diarization - let pyannote auto-detect if num_speakers not specified
71
+ print(f"🔍 Diarization parametreleri: num_speakers={num_speakers}")
72
+
73
  if num_speakers:
74
+ # Use min/max range for better detection
75
+ result = pipeline(audio_path, min_speakers=2, max_speakers=num_speakers)
76
  else:
77
+ # Auto-detect number of speakers
78
  result = pipeline(audio_path)
79
 
80
  # Extract segments from DiarizeOutput object
 
88
  diarization = result
89
 
90
  # Now iterate over the Annotation object
91
+ unique_speakers = set()
92
  for segment, track, speaker in diarization.itertracks(yield_label=True):
93
  segments.append((segment.start, segment.end, speaker))
94
+ unique_speakers.add(speaker)
95
 
96
+ print(f"✅ Diarization tamamlandı: {len(segments)} segment, {len(unique_speakers)} konuşmacı")
97
+ print(f"🔍 Bulunan konuşmacılar: {unique_speakers}")
98
  return segments
99
 
100
  except Exception as e: