mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
Fix defaults for replace_single_newlines variable
This commit is contained in:
@@ -390,7 +390,7 @@ class HandlerDialog(QDialog):
|
|||||||
from abogen.utils import load_config
|
from abogen.utils import load_config
|
||||||
|
|
||||||
cfg = load_config()
|
cfg = load_config()
|
||||||
replace_single_newlines = cfg.get("replace_single_newlines", False)
|
replace_single_newlines = cfg.get("replace_single_newlines", True)
|
||||||
|
|
||||||
cache_key = (self.book_path, mod_time, self.file_type, replace_single_newlines)
|
cache_key = (self.book_path, mod_time, self.file_type, replace_single_newlines)
|
||||||
|
|
||||||
|
|||||||
@@ -2042,7 +2042,7 @@ class ConversionThread(QThread):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Process text and timing
|
# Process text and timing
|
||||||
replace_nl = getattr(self, "replace_single_newlines", False)
|
replace_nl = getattr(self, "replace_single_newlines", True)
|
||||||
processed_text = text.replace("\n", " ") if replace_nl else text
|
processed_text = text.replace("\n", " ") if replace_nl else text
|
||||||
use_gaps = getattr(self, "use_silent_gaps", False)
|
use_gaps = getattr(self, "use_silent_gaps", False)
|
||||||
next_start = (
|
next_start = (
|
||||||
|
|||||||
+2
-2
@@ -1912,7 +1912,7 @@ class abogen(QWidget):
|
|||||||
and queued_item.output_folder == item_queue.output_folder
|
and queued_item.output_folder == item_queue.output_folder
|
||||||
and queued_item.subtitle_mode == item_queue.subtitle_mode
|
and queued_item.subtitle_mode == item_queue.subtitle_mode
|
||||||
and queued_item.output_format == item_queue.output_format
|
and queued_item.output_format == item_queue.output_format
|
||||||
and getattr(queued_item, "replace_single_newlines", False)
|
and getattr(queued_item, "replace_single_newlines", True)
|
||||||
== item_queue.replace_single_newlines
|
== item_queue.replace_single_newlines
|
||||||
and getattr(queued_item, "save_base_path", None)
|
and getattr(queued_item, "save_base_path", None)
|
||||||
== item_queue.save_base_path
|
== item_queue.save_base_path
|
||||||
@@ -1977,7 +1977,7 @@ class abogen(QWidget):
|
|||||||
self.selected_format = queued_item.output_format
|
self.selected_format = queued_item.output_format
|
||||||
self.char_count = queued_item.total_char_count
|
self.char_count = queued_item.total_char_count
|
||||||
self.replace_single_newlines = getattr(
|
self.replace_single_newlines = getattr(
|
||||||
queued_item, "replace_single_newlines", False
|
queued_item, "replace_single_newlines", True
|
||||||
)
|
)
|
||||||
self.use_silent_gaps = getattr(queued_item, "use_silent_gaps", False)
|
self.use_silent_gaps = getattr(queued_item, "use_silent_gaps", False)
|
||||||
# Restore the original file path for save location
|
# Restore the original file path for save location
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ class QueueManager(QDialog):
|
|||||||
f"<b>Subtitle Mode:</b> {getattr(item, 'subtitle_mode', '')}<br>"
|
f"<b>Subtitle Mode:</b> {getattr(item, 'subtitle_mode', '')}<br>"
|
||||||
f"<b>Output Format:</b> {getattr(item, 'output_format', '')}<br>"
|
f"<b>Output Format:</b> {getattr(item, 'output_format', '')}<br>"
|
||||||
f"<b>Characters:</b> {getattr(item, 'total_char_count', '')}<br>"
|
f"<b>Characters:</b> {getattr(item, 'total_char_count', '')}<br>"
|
||||||
f"<b>Replace Single Newlines:</b> {getattr(item, 'replace_single_newlines', False)}<br>"
|
f"<b>Replace Single Newlines:</b> {getattr(item, 'replace_single_newlines', True)}<br>"
|
||||||
f"<b>Use Silent Gaps:</b> {getattr(item, 'use_silent_gaps', False)}<br>"
|
f"<b>Use Silent Gaps:</b> {getattr(item, 'use_silent_gaps', False)}<br>"
|
||||||
f"<b>Speed Method:</b> {getattr(item, 'subtitle_speed_method', 'tts')}"
|
f"<b>Speed Method:</b> {getattr(item, 'subtitle_speed_method', 'tts')}"
|
||||||
)
|
)
|
||||||
@@ -415,7 +415,7 @@ class QueueManager(QDialog):
|
|||||||
attrs["total_char_count"] = getattr(parent, "char_count", "")
|
attrs["total_char_count"] = getattr(parent, "char_count", "")
|
||||||
# replace_single_newlines
|
# replace_single_newlines
|
||||||
attrs["replace_single_newlines"] = getattr(
|
attrs["replace_single_newlines"] = getattr(
|
||||||
parent, "replace_single_newlines", False
|
parent, "replace_single_newlines", True
|
||||||
)
|
)
|
||||||
# use_silent_gaps
|
# use_silent_gaps
|
||||||
attrs["use_silent_gaps"] = getattr(parent, "use_silent_gaps", False)
|
attrs["use_silent_gaps"] = getattr(parent, "use_silent_gaps", False)
|
||||||
@@ -501,8 +501,8 @@ class QueueManager(QDialog):
|
|||||||
== getattr(item, "output_format", None)
|
== getattr(item, "output_format", None)
|
||||||
and getattr(queued_item, "total_char_count", None)
|
and getattr(queued_item, "total_char_count", None)
|
||||||
== getattr(item, "total_char_count", None)
|
== getattr(item, "total_char_count", None)
|
||||||
and getattr(queued_item, "replace_single_newlines", False)
|
and getattr(queued_item, "replace_single_newlines", True)
|
||||||
== getattr(item, "replace_single_newlines", False)
|
== getattr(item, "replace_single_newlines", True)
|
||||||
and getattr(queued_item, "use_silent_gaps", False)
|
and getattr(queued_item, "use_silent_gaps", False)
|
||||||
== getattr(item, "use_silent_gaps", False)
|
== getattr(item, "use_silent_gaps", False)
|
||||||
and getattr(queued_item, "subtitle_speed_method", "tts")
|
and getattr(queued_item, "subtitle_speed_method", "tts")
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class QueuedItem:
|
|||||||
subtitle_mode: str
|
subtitle_mode: str
|
||||||
output_format: str
|
output_format: str
|
||||||
total_char_count: int
|
total_char_count: int
|
||||||
replace_single_newlines: bool = False
|
replace_single_newlines: bool = True
|
||||||
use_silent_gaps: bool = False
|
use_silent_gaps: bool = False
|
||||||
subtitle_speed_method: str = "tts"
|
subtitle_speed_method: str = "tts"
|
||||||
save_base_path: str = None
|
save_base_path: str = None
|
||||||
|
|||||||
+1
-1
@@ -133,7 +133,7 @@ _sleep_procs = {"Darwin": None, "Linux": None} # Store sleep prevention process
|
|||||||
def clean_text(text, *args, **kwargs):
|
def clean_text(text, *args, **kwargs):
|
||||||
# Load replace_single_newlines from config
|
# Load replace_single_newlines from config
|
||||||
cfg = load_config()
|
cfg = load_config()
|
||||||
replace_single_newlines = cfg.get("replace_single_newlines", False)
|
replace_single_newlines = cfg.get("replace_single_newlines", True)
|
||||||
# Collapse all whitespace (excluding newlines) into single spaces per line and trim edges
|
# Collapse all whitespace (excluding newlines) into single spaces per line and trim edges
|
||||||
# Use pre-compiled pattern for better performance
|
# Use pre-compiled pattern for better performance
|
||||||
lines = [_WHITESPACE_PATTERN.sub(" ", line).strip() for line in text.splitlines()]
|
lines = [_WHITESPACE_PATTERN.sub(" ", line).strip() for line in text.splitlines()]
|
||||||
|
|||||||
Reference in New Issue
Block a user