voicemate.pipeline.chunker

Split streamed LLM text into speakable chunks for incremental TTS.

A chunk is emitted as soon as a sentence boundary is certain, so the first sentence is spoken while the model is still generating the rest. The very first chunk of a turn may be cut earlier at a clause boundary (comma, semicolon, colon) to reduce time-to-first-audio.

Attributes

Classes

SpeechChunker

Incremental sentence splitter.

Module Contents

voicemate.pipeline.chunker.ABBREVIATIONS: frozenset[str]
class voicemate.pipeline.chunker.SpeechChunker(min_first_chars: int = 40, max_chars: int = 250)[source]

Incremental sentence splitter.

Parameters:
  • min_first_chars – The first chunk of a turn may end at a clause boundary once it is at least this long.

  • max_chars – Chunks longer than this are cut at the last space.

min_first_chars = 40
max_chars = 250
reset() → None[source]

Forget buffered text; the next chunk counts as the first of a new turn.

feed(text: str) → list[str][source]

Add streamed text and return any chunks that are now complete.

flush() → list[str][source]

Return the remaining text as final chunk(s) at the end of a turn.