TTSModel (tts/base.py)

realtime-phone-agents-course · src/realtime_phone_agents/tts/base.py · python · MIT
voice

Abstract base class defining the interface for Text‑to‑Speech models in a realtime phone agent.

# Source: https://github.com/neural-maze/realtime-phone-agents-course | License: MIT | Copyright 2025 The Neural Maze
# Provided via justclaw.it.com; keep this notice with the code.
from abc import ABC, abstractmethod
from typing import Generator

import numpy as np
from numpy.typing import NDArray


class TTSModel(ABC):
    """
    Abstract base class for Text-to-Speech models.

    All STT model implementations must inherit from this class
    and implement the `tts` and the `stream_tts` methods.
    """

    @abstractmethod
    def tts(self, text: str, **kwargs) -> tuple[int, NDArray[np.int16]]:
        """
        Convert text to speech audio.

        Args:
            text: Text to convert to speech
            **kwargs: Additional model-specific parameters

        Returns:
        

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key