import abc
from _typeshed import Incomplete
from abc import ABC, abstractmethod
from collections.abc import Iterable
from dataclasses import dataclass
from enum import StrEnum
from typing import Final

_SAMPLE_RATE: Final[int]
_SAMPLE_WIDTH: Final[int]

class VadSensitivity(StrEnum):
    DEFAULT: str
    RELAXED: str
    AGGRESSIVE: str
    @staticmethod
    def to_seconds(sensitivity: VadSensitivity | str) -> float: ...

class VoiceActivityDetector(ABC, metaclass=abc.ABCMeta):
    @abstractmethod
    def is_speech(self, chunk: bytes) -> bool: ...
    @property
    @abstractmethod
    def samples_per_chunk(self) -> int | None: ...

class WebRtcVad(VoiceActivityDetector):
    _audio_processor: Incomplete
    def __init__(self) -> None: ...
    def is_speech(self, chunk: bytes) -> bool: ...
    @property
    def samples_per_chunk(self) -> int | None: ...

class AudioBuffer:
    _buffer: Incomplete
    _length: int
    def __init__(self, maxlen: int) -> None: ...
    @property
    def length(self) -> int: ...
    def clear(self) -> None: ...
    def append(self, data: bytes) -> None: ...
    def bytes(self) -> bytes: ...
    def __len__(self) -> int: ...
    def __bool__(self) -> bool: ...

@dataclass
class VoiceCommandSegmenter:
    speech_seconds: float = ...
    silence_seconds: float = ...
    timeout_seconds: float = ...
    reset_seconds: float = ...
    in_command: bool = ...
    _speech_seconds_left: float = ...
    _silence_seconds_left: float = ...
    _timeout_seconds_left: float = ...
    _reset_seconds_left: float = ...
    def __post_init__(self) -> None: ...
    def reset(self) -> None: ...
    def process(self, chunk_seconds: float, is_speech: bool | None) -> bool: ...
    def process_with_vad(self, chunk: bytes, vad: VoiceActivityDetector, leftover_chunk_buffer: AudioBuffer | None) -> bool: ...
    def __init__(self, speech_seconds, silence_seconds, timeout_seconds, reset_seconds, in_command, _speech_seconds_left, _silence_seconds_left, _timeout_seconds_left, _reset_seconds_left) -> None: ...

@dataclass
class VoiceActivityTimeout:
    silence_seconds: float
    reset_seconds: float = ...
    _silence_seconds_left: float = ...
    _reset_seconds_left: float = ...
    def __post_init__(self) -> None: ...
    def reset(self) -> None: ...
    def process(self, chunk_seconds: float, is_speech: bool | None) -> bool: ...
    def __init__(self, silence_seconds, reset_seconds, _silence_seconds_left, _reset_seconds_left) -> None: ...

def chunk_samples(samples: bytes, bytes_per_chunk: int, leftover_chunk_buffer: AudioBuffer) -> Iterable[bytes]: ...
