mirror of
https://github.com/denizsafak/abogen.git
synced 2026-09-20 11:40:57 +02:00
refactor(webui): replace direct VOICES_INTERNAL/DEFAULT_SUPERTONIC_VOICES with get_metadata API
- Add get_default_voice() helper to tts_backend_registry - Replace all VOICES_INTERNAL imports in WebUI with get_metadata().voices - Replace all DEFAULT_SUPERTONIC_VOICES imports in conversion_runner with get_metadata().voices - Remove unused VOICES_INTERNAL import from voices.py Core modules (voice_profiles, voice_formulas, voice_cache) already used get_metadata(). This completes the WebUI migration.
This commit is contained in:
@@ -17,8 +17,8 @@ from abogen.constants import (
|
||||
SUPPORTED_SOUND_FORMATS,
|
||||
SUPPORTED_LANGUAGES_FOR_SUBTITLE_GENERATION,
|
||||
SAMPLE_VOICE_TEXTS,
|
||||
VOICES_INTERNAL,
|
||||
)
|
||||
from abogen.tts_backend_registry import get_metadata
|
||||
from abogen.speaker_configs import list_configs
|
||||
from abogen.tts_backend_registry import create_backend
|
||||
from abogen.webui.conversion_runner import _select_device, _to_float32, SAMPLE_RATE, SPLIT_PATTERN
|
||||
@@ -285,7 +285,7 @@ def filter_voice_catalog(
|
||||
def build_voice_catalog() -> List[Dict[str, str]]:
|
||||
catalog: List[Dict[str, str]] = []
|
||||
gender_map = {"f": "Female", "m": "Male"}
|
||||
for voice_id in VOICES_INTERNAL:
|
||||
for voice_id in get_metadata("kokoro").voices:
|
||||
prefix, _, rest = voice_id.partition("_")
|
||||
language_code = prefix[0] if prefix else "a"
|
||||
gender_code = prefix[1] if len(prefix) > 1 else ""
|
||||
@@ -590,7 +590,7 @@ def template_options() -> Dict[str, Any]:
|
||||
voice_catalog = build_voice_catalog()
|
||||
return {
|
||||
"languages": LANGUAGE_DESCRIPTIONS,
|
||||
"voices": VOICES_INTERNAL,
|
||||
"voices": get_metadata("kokoro").voices,
|
||||
"subtitle_formats": SUBTITLE_FORMATS,
|
||||
"supported_langs_for_subs": SUPPORTED_LANGUAGES_FOR_SUBTITLE_GENERATION,
|
||||
"output_formats": SUPPORTED_SOUND_FORMATS,
|
||||
|
||||
Reference in New Issue
Block a user