From 3171066f0cb4efb8f97159433ca01c55d75a41be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deniz=20=C5=9Eafak?= Date: Mon, 25 Aug 2025 01:34:16 +0300 Subject: [PATCH] Improve karaoke mode and update changelog --- CHANGELOG.md | 4 ++++ abogen/gui.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8569da8..a01fb77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.1.7 (ğre-release) +- Added MPS GPU acceleration support for Silicon Mac, mentioned in https://github.com/denizsafak/abogen/issues/32#issuecomment-3155902040 by @jefro108 +- Added word-by-word karaoke highlighting feature by @robmckinnon in PR #65 + # 1.1.6 - Improved EPUB chapter detection: Now reliably detects chapters from NAV HTML (TOC) files, even in non-standard EPUBs, fixes the issue mentioned by @jefro108 in #33 - Fixed SRT subtitle numbering issue, mentioned by @page-muncher in #41 diff --git a/abogen/gui.py b/abogen/gui.py index de16023..dac5ce0 100644 --- a/abogen/gui.py +++ b/abogen/gui.py @@ -971,6 +971,25 @@ class abogen(QWidget): lambda i: self.set_subtitle_format(self.subtitle_format_combo.itemData(i)) ) subtitle_format_layout.addWidget(self.subtitle_format_combo) + # If subtitle mode requires highlighting, SRT is not supported. Disable SRT item + # and auto-switch to a compatible ASS format if SRT is currently selected. + try: + if hasattr(self, "subtitle_mode") and self.subtitle_mode == "Sentence + Highlighting": + idx_srt = self.subtitle_format_combo.findData("srt") + if idx_srt >= 0: + item = self.subtitle_format_combo.model().item(idx_srt) + if item is not None: + item.setEnabled(False) + # If current selection is SRT, switch to centered narrow ASS + if self.subtitle_format_combo.currentData() == "srt": + new_idx = self.subtitle_format_combo.findData("ass_centered_narrow") + if new_idx >= 0: + self.subtitle_format_combo.setCurrentIndex(new_idx) + # Persist the change + self.set_subtitle_format(self.subtitle_format_combo.itemData(new_idx)) + except Exception: + # Fail-safe: don't crash UI if model manipulation isn't supported on some platforms + pass controls_layout.addLayout(subtitle_format_layout) # Replace single newlines dropdown (acts like checkbox) @@ -2472,6 +2491,30 @@ class abogen(QWidget): self.subtitle_format_combo.setEnabled(False) else: self.subtitle_format_combo.setEnabled(True) + # If highlighting mode selected, SRT is not supported. Disable SRT option and + # switch away from it if currently selected. + try: + idx_srt = self.subtitle_format_combo.findData("srt") + if mode == "Sentence + Highlighting": + if idx_srt >= 0: + item = self.subtitle_format_combo.model().item(idx_srt) + if item is not None: + item.setEnabled(False) + # If current format is SRT, switch to a compatible ASS format + if self.subtitle_format_combo.currentData() == "srt": + new_idx = self.subtitle_format_combo.findData("ass_centered_narrow") + if new_idx >= 0: + self.subtitle_format_combo.setCurrentIndex(new_idx) + self.set_subtitle_format(self.subtitle_format_combo.itemData(new_idx)) + else: + # Re-enable SRT option when not in highlighting mode + if idx_srt >= 0: + item = self.subtitle_format_combo.model().item(idx_srt) + if item is not None: + item.setEnabled(True) + except Exception: + # Ignore errors interacting with model (defensive) + pass def on_format_changed(self, fmt): self.selected_format = fmt