diff --git a/libresvip/plugins/srt/options.py b/libresvip/plugins/srt/options.py index f33bc1df..d80c4521 100644 --- a/libresvip/plugins/srt/options.py +++ b/libresvip/plugins/srt/options.py @@ -43,4 +43,11 @@ class OutputOptions(SelectSingleTrackMixin, BaseModel): description=_("In milliseconds, positive means ahead, negative means opposite."), ) split_by: SplitOption = Field(title=_("New line by"), default=SplitOption.BOTH) + ignore_slur_notes: bool = Field( + title=_("Ignore slur notes"), + description=_( + "Ignore '-' lyrics that are used to indicate slur notes in singing synthesizers." + ), + default=True, + ) encoding: str = Field(title=_("Text encoding"), default="utf-8") diff --git a/libresvip/plugins/srt/srt_generator.py b/libresvip/plugins/srt/srt_generator.py index 28faf77b..b5c8656c 100644 --- a/libresvip/plugins/srt/srt_generator.py +++ b/libresvip/plugins/srt/srt_generator.py @@ -45,6 +45,12 @@ def generate_project(self, project: Project) -> SSAFile: buffer = [] return lyric_lines + def lyric_included(self, lyric: str) -> bool: + if self.options.ignore_slur_notes: + return lyric != "-" + else: + return True + def commit_current_lyric_line(self, lyric_lines: list[SSAEvent], buffer: list[Note]) -> None: start_time = int(self.synchronizer.get_actual_secs_from_ticks(buffer[0].start_pos) * 1000) end_time = int(self.synchronizer.get_actual_secs_from_ticks(buffer[-1].end_pos) * 1000) @@ -52,6 +58,7 @@ def commit_current_lyric_line(self, lyric_lines: list[SSAEvent], buffer: list[No SYMBOL_PATTERN.sub("", note.lyric) + (" " if LATIN_ALPHABET.search(note.lyric) is not None else "") for note in buffer + if self.lyric_included(note.lyric) ).strip() lyric_lines.append( SSAEvent(