Pocket TTS
This directory contains:
- a PyTorch reference implementation;
- a TTNN inference implementation;
- reference and TTNN demos;
- PCC and end-to-end tests.
1. Directory Structure
models/bos_model/audio/pocket_tts/
├── README.md
├── demo/
│ ├── demo.py
│ └── tt_demo.py
├── reference/
├── tt/
└── tests/
├── conditioners/
├── modules/
├── models/
└── test.py
The reference/ implementation is the numerical baseline.
The tt/ implementation uses TTNN for supported FlowLM and Mimi inference operations.
2. Environment Setup
From the TT-Metal repository root:
source env_set.sh pockettts
models/bos_model/audio/pocket_tts/setup.sh
This uses the repository's standard shared python_env; a PocketTTS-specific
environment is not required. If the shared environment does not exist yet,
build TT-Metal and run ./create_venv.sh default once before running setup.sh.
PocketTTS 2.1.0 declares numpy>=2, while TTNN requires numpy<2. The model
uses only NumPy APIs supported by the repository's existing NumPy 1.26 package,
so setup.sh installs PocketTTS without resolving its dependencies and adds
only the missing compatible runtime packages from requirements.txt. This
avoids upgrading the shared NumPy installation.
Verify the setup:
python - <<'PY'
from importlib.metadata import version
import numpy
import pocket_tts
import safetensors
import scipy
import torch
print("torch =", torch.__version__)
print("numpy =", numpy.__version__)
print("scipy =", scipy.__version__)
print("safetensors =", safetensors.__version__)
print("pocket-tts =", version("pocket-tts"))
print("module path =", pocket_tts.__file__)
PY
python -m pytest models/bos_model/audio/pocket_tts/tests --collect-only -q
Run the complete PocketTTS suite on a configured TT system:
python -m pytest models/bos_model/audio/pocket_tts/tests -q
3. TTNN Demo and Benchmark
Run the TTNN demo:
python models/bos_model/audio/pocket_tts/demo/tt_demo.py
Without --benchmark, the demo generates one audio result and does not collect
or report timing metrics. Enable device-only timing explicitly:
python models/bos_model/audio/pocket_tts/demo/tt_demo.py \
--text "Hello!" \
--voice-source alba \
--benchmark device_only \
--warmup-runs 3 \
--measured-runs 20
To measure synchronized wall-clock generation time, including host execution:
python models/bos_model/audio/pocket_tts/demo/tt_demo.py \
--text "Hello!" \
--voice-source alba \
--benchmark include_host_time \
--warmup-runs 3 \
--measured-runs 20
Run python models/bos_model/audio/pocket_tts/demo/tt_demo.py --help for the
complete option list.
Warmup runs are excluded from benchmark statistics. In device_only mode, the
demo enables the TT device profiler before TTNN starts and requires a
Tracy-enabled build. In include_host_time mode, it measures synchronized
wall-clock time around generate() without enabling the device profiler.
Device-only reporting includes:
Mean, median, minimum, maximum, standard deviation, and CV of device kernel time
Acoustic Transformer/LSD device kernel time in seconds
Codec/Vocoder device kernel time in seconds
Device-only RTF
Device-only RTFx (generated audio seconds per device kernel second)
Device program execution count
For each device-only run, the benchmark reads DEVICE KERNEL DURATION [ns] from
TTNN's programmatic device-profiler results. Program durations are summed on
each chip; when multiple chips run in parallel, the slowest chip is reported.
The profiler is flushed before every run and at bounded model-region boundaries
during the run, preventing profiler-buffer overflow. Each run has an independent
accumulator, so setup programs and warmup statistics cannot leak into measured
runs.
The acoustic stage aggregates FlowLM transformer prefill, autoregressive transformer decode, and FlowNet/LSD kernels. The codec/vocoder stage aggregates the Mimi quantizer, frame upsampler, decoder transformer, and SEANet decoder. Both are subsets of total device kernel time; uncategorized device work can make their sum smaller than the total.
RTF and RTFx are calculated as:
Device-only RTF = active device kernel time / generated audio duration
Device-only RTFx = generated audio duration / active device kernel time
Host dispatch, synchronization, Python control flow, host/device transfer time, waveform validation, model loading, voice preparation, and WAV writing are not included in device kernel time or device-only RTF.
Host-inclusive timing includes Python generation control flow, host dispatch,
device execution, transfers performed inside generate(), and final device
synchronization. It excludes model loading, voice preparation, post-generation
waveform validation, and WAV writing.
Interpretation:
RTF < 1.0 faster than real time
RTF = 1.0 real time
RTF > 1.0 slower than real time