Skip to Content
🎬Video-Labs
Engine Architecture

Voice Engine Architecture

tts/engine.py, BaseVoiceEngine, SSML handling, and alignment generation.

All speech synthesizers in Video-Labs subclass BaseVoiceEngine in tts/engine.py.


1. The BaseVoiceEngine Interface

class BaseVoiceEngine(ABC):
    @abstractmethod
    def synthesize(self, text: str, voice: str, speed: float = 1.0) -> AudioResult:
        """
        Synthesizes audio and extracts word-level timing boundaries.
        Returns:
            audio_bytes: 24 kHz mono uncompressed PCM audio.
            timeline: List of { word, start, end } timestamp objects.
        """
        pass

2. Supported Engine Adapters

  1. EdgeTTSEngine: Converts text to SSML with <prosody rate="..." pitch="...">. Reads Microsoft streaming subtitle events to extract exact word timings.
  2. KokoroEngine: Runs local PyTorch weights on Apple Silicon MPS device. Extracts phoneme durations directly from model hidden states.
  3. MeloTTSEngine: Multi-accented local neural engine for British, American, and Indian English accents.
  4. Qwen3TTSEngine: Alibaba Qwen3-TTS engine with pre-flight model caching checks.
  5. ElevenLabsEngine: Cloud API client for studio-grade voice cloning.

On this page