Merge pull request #94 from mleg/main

Add `Line` option for subtitle generation

Thank you, merged!
This commit is contained in:
Deniz Şafak
2025-10-08 00:13:40 +03:00
committed by GitHub
2 changed files with 9 additions and 3 deletions
+7 -2
View File
@@ -1255,9 +1255,14 @@ class ConversionThread(QThread):
if end is None or end <= start or end <= 0:
subtitle_entries[-1] = (start, fallback_end_time, text)
elif self.subtitle_mode == "Sentence" or self.subtitle_mode == "Sentence + Comma":
elif self.subtitle_mode in ["Sentence", "Sentence + Comma", "Line"]:
# Define separator pattern based on mode
separator = r"[.!?]" if self.subtitle_mode == "Sentence" else r"[.!?,]"
if self.subtitle_mode == "Line":
separator = r"\n"
elif self.subtitle_mode == "Sentence":
separator = r"[.!?]"
else: # Sentence + Comma
separator = r"[.!?,]"
current_sentence = []
word_count = 0
+2 -1
View File
@@ -953,6 +953,7 @@ class abogen(QWidget):
self.subtitle_combo.setToolTip(
"Choose how subtitles will be generated:\n"
"Disabled: No subtitles will be generated.\n"
"Line: Subtitles will be generated for each line.\n"
"Sentence: Subtitles will be generated for each sentence.\n"
"Sentence + Comma: Subtitles will be generated for each sentence and comma.\n"
"Sentence + Highlighting: Subtitles with word-by-word karaoke highlighting.\n"
@@ -963,7 +964,7 @@ class abogen(QWidget):
for lang in SUPPORTED_LANGUAGES_FOR_SUBTITLE_GENERATION
)
)
subtitle_options = ["Disabled", "Sentence", "Sentence + Comma", "Sentence + Highlighting"] + [
subtitle_options = ["Disabled", "Line", "Sentence", "Sentence + Comma", "Sentence + Highlighting"] + [
f"{i} word" if i == 1 else f"{i} words" for i in range(1, 11)
]
self.subtitle_combo.addItems(subtitle_options)