Update pipeline/postprocess.py
Browse files- 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 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
|