feat: Add TTSBackendMetadata model

This commit is contained in:
Artem Akymenko
2026-07-06 12:58:06 +03:00
parent 56d3e414b3
commit 45e859dac4
2 changed files with 52 additions and 1 deletions
+23 -1
View File
@@ -1,12 +1,30 @@
""" """
TTS Backend Interface TTS Backend Interface
This module defines the protocol for TTS backends. This module defines the protocol for TTS backends and the
metadata model that describes a backend implementation.
""" """
from dataclasses import dataclass
from typing import Protocol, List, Dict, Any from typing import Protocol, List, Dict, Any
@dataclass(frozen=True)
class TTSBackendMetadata:
"""
Immutable metadata describing a TTS backend implementation.
Attributes:
id: Unique backend identifier (e.g. ``"kokoro"``, ``"supertonic"``).
name: Human-readable display name.
description: Short description of the backend.
"""
id: str
name: str
description: str
class TTSBackend(Protocol): class TTSBackend(Protocol):
""" """
Protocol for TTS backends. Protocol for TTS backends.
@@ -15,6 +33,10 @@ class TTSBackend(Protocol):
with the application. with the application.
""" """
@property
def metadata(self) -> TTSBackendMetadata:
...
def __init__(self, **kwargs) -> None: def __init__(self, **kwargs) -> None:
""" """
Initialize the TTS backend. Initialize the TTS backend.
+29
View File
@@ -0,0 +1,29 @@
from dataclasses import dataclass
from abogen.tts_backend import TTSBackendMetadata
class TestTTSBackendMetadata:
def test_is_frozen_dataclass(self):
assert dataclass(TTSBackendMetadata)
def test_fields_are_present(self):
meta = TTSBackendMetadata(
id="test",
name="Test Backend",
description="A test backend",
)
assert meta.id == "test"
assert meta.name == "Test Backend"
assert meta.description == "A test backend"
def test_is_immutable(self):
import pytest
meta = TTSBackendMetadata(
id="kokoro",
name="Kokoro",
description="Test",
)
with pytest.raises(Exception):
meta.id = "changed"