File size: 797 Bytes
11c4a5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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