mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 21:50:28 +02:00
refactor(webui): rename preview.py to synthesize.py and remove dead code
- Rename abogen/webui/routes/utils/preview.py → synthesize.py The file contains the core TTS synthesis pipeline (generate_preview_audio, synthesize_preview), not just preview logic. Name now matches responsibility. - Remove dead code from voice.py: get_preview_pipeline(), synthesize_audio_from_normalized(), _preview_pipeline_lock, _preview_pipelines, and unused imports (threading, numpy, create_pipeline, get_new_voice, _select_device, _to_float32, SAMPLE_RATE, SPLIT_PATTERN). These were never called — identical logic lives in synthesize.py. - Update imports in api.py, voices.py, and test_preview_applies_manual_overrides.py - 7 new tests in test_synthesize_module.py enforce file naming and import rules - 7 tests in test_domain_imports.py updated for renamed module
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
from abogen.webui.routes.utils import preview
|
||||
from abogen.webui.routes.utils import synthesize
|
||||
|
||||
|
||||
def test_preview_applies_manual_override_before_normalization(monkeypatch):
|
||||
# Don't run real TTS/normalization; just exercise the override stage by
|
||||
# forcing provider=kokoro and then stubbing normalize_for_pipeline.
|
||||
|
||||
monkeypatch.setattr(preview, "get_preview_pipeline", lambda language, device: None)
|
||||
monkeypatch.setattr(synthesize, "get_preview_pipeline", lambda language, device: None)
|
||||
|
||||
# Stub normalize_for_pipeline to be identity; we only care that overrides run.
|
||||
class _Norm:
|
||||
@@ -42,7 +42,7 @@ def test_preview_applies_manual_override_before_normalization(monkeypatch):
|
||||
monkeypatch.setattr(utils, "create_pipeline", _mock_create_pipeline)
|
||||
|
||||
try:
|
||||
preview.generate_preview_audio(
|
||||
synthesize.generate_preview_audio(
|
||||
text="He said Unfu*k loudly.",
|
||||
voice_spec="M1",
|
||||
language="en",
|
||||
|
||||
Reference in New Issue
Block a user