Skip to content

Commit

Permalink
Merge pull request #374 from jhj0517/fix/diarization
Browse files Browse the repository at this point in the history
Fix diarization
  • Loading branch information
jhj0517 authored Nov 2, 2024
2 parents 0295d69 + d18bcd4 commit f12a40c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions modules/diarize/diarize_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ def __call__(self, audio: Union[str, np.ndarray], min_speakers=None, max_speaker

def assign_word_speakers(diarize_df, transcript_result, fill_nearest=False):
transcript_segments = transcript_result["segments"]
if transcript_segments and isinstance(transcript_segments[0], Segment):
transcript_segments = [seg.model_dump() for seg in transcript_segments]
for seg in transcript_segments:
if isinstance(seg, Segment):
seg = seg.model_dump()
# assign speaker to segment (if any)
diarize_df['intersection'] = np.minimum(diarize_df['end'], seg['end']) - np.maximum(diarize_df['start'],
seg['start'])
Expand Down Expand Up @@ -88,7 +88,7 @@ def assign_word_speakers(diarize_df, transcript_result, fill_nearest=False):
if word_speaker is not None:
word["speaker"] = word_speaker

return transcript_result
return {"segments": transcript_segments}


class DiarizationSegment:
Expand Down
1 change: 0 additions & 1 deletion modules/diarize/diarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def run(self,

segments_result = []
for segment in diarized_result["segments"]:
segment = segment.dict()
speaker = "None"
if "speaker" in segment:
speaker = segment["speaker"]
Expand Down

0 comments on commit f12a40c

Please sign in to comment.