from abc import ABC, abstractmethod from typing import Any, Iterable class IVoiceActivityEngine(ABC): """Contract for a Voice Activity Detector (VAD).""" @abstractmethod def __call__(self, audio_chunk: bytes) -> bool: """ Analyzes an audio chunk and returns True if speech is detected, False otherwise. """ pass class IStreamingSpeechEngine(ABC): """Contract for a streaming transcription service.""" @abstractmethod def transcribe_chunk(self, audio_chunk: bytes) -> str: """Processes an audio chunk and returns a transcription (partial or final).""" pass @abstractmethod def finalize_segment(self) -> str: """Called at the end of the stream to get the final transcription.""" pass