feat: Supertonic language + total_steps propagation

Language enum expanded from 9 to 33 languages:
- Added 24 new ISO 639-1 languages: AR, BG, CS, DA, DE, EL, ET, FI,
  HR, HU, ID, KO, LT, LV, NL, PL, RO, RU, SK, SL, SV, TR, UK, VI
- Updated display_name, is_cjk (added KO)

Supertonic language mapping (32 languages, no ZH):
- engine.py: _SUPERTONIC_LANG_MAP, engine_language(), supported_languages()
- __init__.py: create_engine() passes config.language to pipeline
- pipeline.py: __init__() accepts language, resolves to ISO code;
  __call__() passes lang= to TTS.synthesize()

total_steps propagation:
- tts_segments(): +total_steps param, conditionally passed to backend
- synthesize_text(): +total_steps param
- run_tts_segment_loop(): +total_steps param
- executor: all 5 synthesize_text() calls pass total_steps

Integration:
- pipeline_factory: create_pipeline_for_job() passes language to supertonic
- preview path: create_pipeline('supertonic', language=language)

Tests updated to accept total_steps in FakeBackend.__call__
This commit is contained in:
Artem Akymenko
2026-07-28 14:09:42 +03:00
parent 953bef1e71
commit 2b70b9ca45
14 changed files with 146 additions and 15 deletions
+56
View File
@@ -12,6 +12,7 @@ from typing import Any
import numpy as np
from abogen.domain.enums import Language
from abogen.tts_plugin.capabilities import VoiceLister
from abogen.tts_plugin.engine import Engine, EngineSession
from abogen.tts_plugin.errors import EngineError
@@ -28,6 +29,61 @@ logger = logging.getLogger(__name__)
# Sample rate for SuperTonic audio
_SUPERTONIC_SAMPLE_RATE = 24000
# Engine-internal language mapping: Language enum → Supertonic ISO 639-1 code.
_SUPERTONIC_LANG_MAP: dict[Language, str] = {
Language.EN_US: "en",
Language.EN_GB: "en",
Language.AR: "ar",
Language.BG: "bg",
Language.CS: "cs",
Language.DA: "da",
Language.DE: "de",
Language.EL: "el",
Language.ES: "es",
Language.ET: "et",
Language.FI: "fi",
Language.FR: "fr",
Language.HI: "hi",
Language.HR: "hr",
Language.HU: "hu",
Language.ID: "id",
Language.IT: "it",
Language.JA: "ja",
Language.KO: "ko",
Language.LT: "lt",
Language.LV: "lv",
Language.NL: "nl",
Language.PL: "pl",
Language.PT_BR: "pt",
Language.RO: "ro",
Language.RU: "ru",
Language.SK: "sk",
Language.SL: "sl",
Language.SV: "sv",
Language.TR: "tr",
Language.UK: "uk",
Language.VI: "vi",
}
def supported_languages() -> list[Language]:
"""Return the list of Language enum values this engine supports."""
return list(_SUPERTONIC_LANG_MAP.keys())
def engine_language(lang: Language) -> str:
"""Map a Language enum to the engine's internal ISO 639-1 code.
Raises ValueError for unsupported languages.
"""
result = _SUPERTONIC_LANG_MAP.get(lang)
if result is None:
raise ValueError(
f"Supertonic does not support language: {lang!r}. "
f"Supported: {supported_languages()}"
)
return result
class SuperTonicSession:
"""EngineSession implementation for SuperTonic.