Skip to content

Commit 2efa275

Browse files
committed
Fix type issue
1 parent 46f7c1b commit 2efa275

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

modules/diarize/diarize_pipeline.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from typing import Optional, Union
88
import torch
99

10+
from modules.whisper.data_classes import *
1011
from modules.utils.paths import DIARIZATION_MODELS_DIR
1112
from modules.diarize.audio_loader import load_audio, SAMPLE_RATE
1213

@@ -44,7 +45,8 @@ def __call__(self, audio: Union[str, np.ndarray], min_speakers=None, max_speaker
4445
def assign_word_speakers(diarize_df, transcript_result, fill_nearest=False):
4546
transcript_segments = transcript_result["segments"]
4647
for seg in transcript_segments:
47-
seg = seg.dict()
48+
if isinstance(seg, Segment):
49+
seg = seg.model_dump()
4850
# assign speaker to segment (if any)
4951
diarize_df['intersection'] = np.minimum(diarize_df['end'], seg['end']) - np.maximum(diarize_df['start'],
5052
seg['start'])
@@ -64,7 +66,7 @@ def assign_word_speakers(diarize_df, transcript_result, fill_nearest=False):
6466
seg["speaker"] = speaker
6567

6668
# assign speaker to words
67-
if 'words' in seg:
69+
if 'words' in seg and seg['words'] is not None:
6870
for word in seg['words']:
6971
if 'start' in word:
7072
diarize_df['intersection'] = np.minimum(diarize_df['end'], word['end']) - np.maximum(
@@ -89,7 +91,7 @@ def assign_word_speakers(diarize_df, transcript_result, fill_nearest=False):
8991
return transcript_result
9092

9193

92-
class Segment:
94+
class DiarizationSegment:
9395
def __init__(self, start, end, speaker=None):
9496
self.start = start
9597
self.end = end

0 commit comments

Comments
 (0)