$ show kyutai-labs/pocket-tts
pocket-tts is a production-ready text-to-speech library and application optimized for CPU inference. It provides a Python API, CLI (generate, serve, export-voice), and a FastAPI web server with streaming WAV output. The core architecture uses a FlowLMModel (transformer + flow matching with LSD) and a Mimi neural audio codec, with streaming inference via KV caching. It supports multiple languages (English, French, German, Portuguese, Italian, Spanish), voice cloning from audio prompts, and quantization (int8 dynamic) for efficiency. The repository also includes a full training pipeline (data preparation, alignment, tokenizer training, distributed training, distillation) and evaluation scripts. While primarily an application, the training code adds a research dimension. The codebase is modular and well-documented, with reusable components like stateful streaming modules, quantization utilities, and rotary embeddings. Some technical debt exists (deprecated quantization backend, hardcoded thread settings, multiple config versions), but overall it is a solid, actively maintained project.
The LLM identified 4 files worth highlighting for reuse:
Provides a base class `StatefulModule` for implementing streaming inference with state management (init, get, set state, increment step). Self-contained (only depends on torch and typing). Can be reused in any model requiring incremental processing with state caching, e.g., autoregressive decoders or streaming transformers.
Implements `apply_dynamic_int8` for per-layer-group quantization of linear layers using torchao (preferred) with fallback to torch.ao. Self-contained, handles edge cases (CPU-only, mixed precision). Reusable in any PyTorch project needing fast int8 quantization without full calibration.
Implements Rotary Position Embedding (RoPE) with support for streaming (precomputed cos/sin tables and offset tracking). Self-contained (depends only on torch). Can be extracted and reused in any transformer-based model requiring relative position encoding with sequence continuation.
Provides text splitting logic for TTS: splits text into sentences using regex and handles special markers (SSML-style tags, <break>). Self-contained, no internal dependencies. Reusable for any NLP task that requires sentence segmentation or chunking with custom delimiters.