"""In-memory PCM ring buffer for a single utterance. Kept deliberately dependency-free (REQ-002). The buffer accumulates the current utterance's PCM and is flushed at end-of-speech, so STT always transcribes one utterance, not a rolling window. """ from __future__ import annotations class PCMBuffer: def __init__(self) -> None: self._chunks: list[bytes] = [] self._bytes = 0 def feed(self, pcm: bytes) -> None: self._chunks.append(bytes(pcm)) self._bytes += len(pcm) def total_bytes(self) -> int: return self._bytes def get(self) -> bytes: data = b"".join(self._chunks) self.clear() return data def clear(self) -> None: self._chunks = [] self._bytes = 0