canary_aed_streaming / app /interfaces.py
Archime's picture
add nemo_asr and silero_vad Engine
11c4a5a
raw
history blame contribute delete
797 Bytes
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