decipher.stream

A categorical sequence paired with the audio each symbol indexes.

dataclass decipher.stream.SymbolStream
@dataclass
class SymbolStream:
    symbols: np.ndarray           # int, 1-D, in [0, alphabet_size)
    alphabet_size: int
    units: list                   # parallel to symbols; each holds source_samples + sr
    source_sr: int                # parent recording sample rate
    session_boundaries: list[tuple[int, int]] = []   # half-open intervals over symbols
    name: str = ""

    def __len__(self) -> int

The constructor validates: symbols is 1-D integer, symbols and units align, every symbol id is in range, and (if non-empty) session_boundaries cover [0, N) exactly once.

function decipher.stream.split_sessions
def split_sessions(
    units: Sequence,
    gap_s: float,
) -> list[tuple[int, int]]

Returns half-open (start, end) index intervals. Two units belong to the same session iff units[i].start_s - units[i-1].end_s ≤ gap_s. Use the result to populate SymbolStream.session_boundaries.