refactor: group ConversionRequest fields into config objects

Domain config types (domain/config_types.py):
- PronunciationConfig: pronunciation/heteronym/normalization overrides
- SubtitleConfig: mode, format, max_words
- CoverConfig: path, mime

Domain functions now accept config objects:
- build_tts_context(subtitle=, pronunciation=) instead of 9 individual params
- make_subtitle_writer(subtitle=) instead of 3 params
- process_and_write_subtitles(subtitle=) instead of 2 params
- embed_m4b_metadata(cover=) instead of 2 params
- build_epub3_package(cover=) instead of 2 params

ConversionRequest: 18 flat fields + 8 config objects
Application/config.py re-exports domain types
All tests updated to new API
This commit is contained in:
Artem Akymenko
2026-07-28 13:41:45 +03:00
parent 146cc81271
commit 953bef1e71
19 changed files with 354 additions and 257 deletions
+7 -11
View File
@@ -14,7 +14,8 @@ from unittest.mock import MagicMock, patch
from dataclasses import dataclass, field
from typing import Any
from abogen.domain.enums import Language
from abogen.domain.config_types import SubtitleConfig
from abogen.domain.enums import Language, SubtitleMode
from abogen.domain.conversion_engine import (
synthesize_text,
SynthParams,
@@ -253,8 +254,7 @@ class TestProcessAndWriteSubtitles:
process_and_write_subtitles(
[],
writer,
subtitle_mode="Sentence",
max_subtitle_words=5,
subtitle=SubtitleConfig(mode=SubtitleMode.SENTENCE, max_words=5),
language=Language.EN_US,
use_spacy_segmentation=False,
fallback_end_time=10.0,
@@ -270,8 +270,7 @@ class TestProcessAndWriteSubtitles:
process_and_write_subtitles(
tokens,
writer,
subtitle_mode="Sentence",
max_subtitle_words=5,
subtitle=SubtitleConfig(mode=SubtitleMode.SENTENCE, max_words=5),
language=Language.EN_US,
use_spacy_segmentation=False,
fallback_end_time=2.0,
@@ -292,8 +291,7 @@ class TestProcessAndWriteSubtitles:
process_and_write_subtitles(
tokens,
writer,
subtitle_mode="Line",
max_subtitle_words=5,
subtitle=SubtitleConfig(mode=SubtitleMode.LINE, max_words=5),
language=Language.EN_US,
use_spacy_segmentation=False,
fallback_end_time=3.0,
@@ -311,8 +309,7 @@ class TestProcessAndWriteSubtitles:
process_and_write_subtitles(
tokens,
writer,
subtitle_mode="Disabled",
max_subtitle_words=5,
subtitle=SubtitleConfig(mode=SubtitleMode.DISABLED, max_words=5),
language=Language.EN_US,
use_spacy_segmentation=False,
fallback_end_time=2.0,
@@ -366,8 +363,7 @@ class TestFullPipeline:
process_and_write_subtitles(
tokens,
subtitle_writer,
subtitle_mode="Sentence",
max_subtitle_words=5,
subtitle=SubtitleConfig(mode=SubtitleMode.SENTENCE, max_words=5),
language=Language.EN_US,
use_spacy_segmentation=False,
fallback_end_time=stats.current_time,