Abstract base class defining the interface for speech‑to‑text models.
# 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 Union
class STTModel(ABC):
"""
Abstract base class for Speech-to-Text models.
All STT model implementations must inherit from this class
and implement the stt method.
"""
@abstractmethod
async def stt(self, audio_data: Union[bytes, str], **kwargs) -> str:
"""
Convert speech audio to text.
Args:
audio_data: Audio data as bytes or path to audio file
**kwargs: Additional model-specific parameters
Returns:
str: Transcribed text from the audio
Raises:
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key