AliJabbarpour commited on
Commit
9e7707f
·
verified ·
1 Parent(s): 1619f99

Update pipeline/postprocess.py

Browse files
Files changed (1) hide show
  1. pipeline/postprocess.py +10 -4
pipeline/postprocess.py CHANGED
@@ -38,12 +38,18 @@ def merge_segments(segments: list) -> list:
38
  combined_duration = seg["end"] - current["start"]
39
  ends_sentence = current["text"].rstrip().endswith((".", "!", "?"))
40
 
 
 
 
 
41
  should_merge = (
42
- len(combined_text) <= MERGE_MAX_CHARS
43
  and combined_duration <= MAX_DISPLAY
44
- and gap <= MAX_GAP
45
- and not ends_sentence
46
- )
 
 
47
 
48
  if should_merge:
49
  current["text"] = combined_text
 
38
  combined_duration = seg["end"] - current["start"]
39
  ends_sentence = current["text"].rstrip().endswith((".", "!", "?"))
40
 
41
+ # segment کوتاه — همیشه merge کن
42
+ current_words = current.get("words", [])
43
+ is_short = len(current_words) <= 2 or (current["end"] - current["start"]) < 0.8
44
+
45
  should_merge = (
46
+ not ends_sentence
47
  and combined_duration <= MAX_DISPLAY
48
+ and (
49
+ is_short # segment کوتاه رو همیشه merge کن
50
+ or (len(combined_text) <= MERGE_MAX_CHARS and gap <= MAX_GAP)
51
+ )
52
+ )
53
 
54
  if should_merge:
55
  current["text"] = combined_text