mirror of
https://github.com/denizsafak/abogen.git
synced 2026-09-20 19:50:59 +02:00
refactor: dynamic ConversionRequest validation, remove 'or default' from adapters
- __post_init__: _apply_none_defaults() iterates dataclasses.fields() dynamically - _NUMERIC_CONSTRAINTS and _ENUM_CONSTRAINTS dicts replace per-field if chains - Both adapters pass values as-is (no 'or default' fallbacks) - 18 validation tests + updated adapter tests for Enum assertions
This commit is contained in:
@@ -60,28 +60,28 @@ def build_conversion_request_from_thread(thread: Any) -> ConversionRequest:
|
||||
direct_text=thread.file_name if is_direct_text else None,
|
||||
original_filename=original_filename,
|
||||
# TTS Settings
|
||||
language=thread.lang_code or "a",
|
||||
language=thread.lang_code,
|
||||
tts_provider="kokoro", # PyQt uses Kokoro by default
|
||||
voice=thread.voice or "M1",
|
||||
voice=thread.voice,
|
||||
voice_profile=getattr(thread, "voice_profile", None),
|
||||
speed=thread.speed or 1.0,
|
||||
speed=thread.speed,
|
||||
use_gpu=thread.use_gpu,
|
||||
supertonic_total_steps=getattr(thread, "supertonic_total_steps", None) or 5,
|
||||
supertonic_total_steps=getattr(thread, "supertonic_total_steps", 5),
|
||||
# Output Format
|
||||
output_format=thread.output_format or "wav",
|
||||
subtitle_mode=thread.subtitle_mode or "Disabled",
|
||||
output_format=thread.output_format,
|
||||
subtitle_mode=thread.subtitle_mode,
|
||||
subtitle_format=getattr(thread, "subtitle_format", "srt"),
|
||||
max_subtitle_words=getattr(thread, "max_subtitle_words", None) or 50,
|
||||
max_subtitle_words=getattr(thread, "max_subtitle_words", 50),
|
||||
# Save Options
|
||||
save_mode=thread.save_option or "save_next_to_input",
|
||||
save_mode=thread.save_option,
|
||||
output_folder=output_folder,
|
||||
save_chapters_separately=getattr(thread, "save_chapters_separately", False),
|
||||
merge_chapters_at_end=getattr(thread, "merge_chapters_at_end", True),
|
||||
separate_chapters_format=getattr(thread, "separate_chapters_format", "wav"),
|
||||
save_as_project=getattr(thread, "save_as_project", False),
|
||||
# Timing
|
||||
silence_between_chapters=getattr(thread, "silence_duration", None) or 2.0,
|
||||
chapter_intro_delay=getattr(thread, "chapter_intro_delay", None) or 0.0,
|
||||
silence_between_chapters=getattr(thread, "silence_duration", 2.0),
|
||||
chapter_intro_delay=getattr(thread, "chapter_intro_delay", 0.0),
|
||||
# Content Processing
|
||||
replace_single_newlines=getattr(thread, "replace_single_newlines", False),
|
||||
read_title_intro=getattr(thread, "read_title_intro", False),
|
||||
|
||||
Reference in New Issue
Block a user