AliJabbarpour commited on
Commit
9c33bd0
·
verified ·
1 Parent(s): 6f452b7

Update pipeline/postprocess.py

Browse files
Files changed (1) hide show
  1. pipeline/postprocess.py +6 -2
pipeline/postprocess.py CHANGED
@@ -39,13 +39,17 @@ def merge_segments(segments: list) -> list:
39
  ends_sentence = current["text"].rstrip().endswith((".", "!", "?"))
40
  current_duration = current["end"] - current["start"]
41
  is_short = current_duration < 1.5
 
42
 
43
  should_merge = (
44
  not ends_sentence
45
  and combined_duration <= MAX_DISPLAY
46
  and (
47
- is_short
48
- or (len(combined_text) <= MERGE_MAX_CHARS and gap <= MAX_GAP)
 
 
 
49
  )
50
  )
51
 
 
39
  ends_sentence = current["text"].rstrip().endswith((".", "!", "?"))
40
  current_duration = current["end"] - current["start"]
41
  is_short = current_duration < 1.5
42
+ same_speaker = current.get("speaker") is None or current.get("speaker") == seg.get("speaker")
43
 
44
  should_merge = (
45
  not ends_sentence
46
  and combined_duration <= MAX_DISPLAY
47
  and (
48
+ same_speaker
49
+ and (
50
+ is_short
51
+ or (len(combined_text) <= MERGE_MAX_CHARS and gap <= MAX_GAP)
52
+ )
53
  )
54
  )
55