Open-source State-of-the-art TTS model which runs on a CPU π»
Python
Prepare 0.9.7 and simplify GPU setup documentation
haaziq-sl302a0b0ef12d
diff --git a/README.md b/README.mdindex 2c2c824..47791ef 100644--- a/README.md+++ b/README.md@@ -48,7 +48,7 @@ The library also ships our existing [**lightweight V0.8 models**](docs/onnx-mode## Features- **Voice cloning** -- Clone any speaker from 5-30 seconds of audio, no fine-tuning-- **47 built-in voices** -- Including the eight from KittenTTS 0.8 and nine non-English+- **115 built-in voices** -- Including the eight from KittenTTS 0.8- **Multilingual** -- 20 languages: English, Arabic, Chinese, French, German, Hindi, Italian, Portuguese, Russian, Spanish, Japanese, Korean, Turkish, Dutch, Swedish, Danish, Finnish, Swahili, Greek, Hebrew- **Expression control** -- `[emotion]` tags, inline `<event>` tags, and `(((emphasis)))` spans- **Decoding presets** -- Trade stability against expressiveness per request@@ -69,7 +69,7 @@ The library also ships our existing [**lightweight V0.8 models**](docs/onnx-mode| Model | Parameters | Size | Voices | Download ||---|---|---|---|---|-| kitten-tts-2 | 1.7B | 506 MiB | 47 + cloning | [KittenML/kitten-tts-2](https://huggingface.co/KittenML/kitten-tts-2) |+| kitten-tts-2 | 1.7B | 492 MB | 115 + cloning | [KittenML/kitten-tts-2](https://huggingface.co/KittenML/kitten-tts-2) |**Lightweight ONNX** -- runs on CPU, no GPU required:@@ -103,9 +103,9 @@ Or run the Gradio demo locally: `pip install kittenml gradio`, then `python grad### Prerequisites-- Python 3.9 or later+- Python 3.10 or later- A CUDA GPU with roughly 8 GB free, or a CPU with about 6 GB of RAM-- About 1 GB of disk space for the model, or 506 MiB with the smaller weights+- About 2 GB of disk space for the model and audio decoder, plus Python dependencies### Installation@@ -113,10 +113,12 @@ Or run the Gradio demo locally: `pip install kittenml gradio`, then `python gradpip install kittenml```-That is the whole install. KittenTTS 2 is the default model, voice cloning is included, and no-Hugging Face login is needed -- every weight the model uses ships in its own repository. It also-pulls the small ONNX runtime, so the [lightweight models](docs/onnx-models.md) work from the-same install.+For NVIDIA GPU support, use a [PyTorch CUDA build](https://pytorch.org/get-started/locally/)+compatible with your driver. If PyTorch reports a missing Visual C++ runtime on Windows,+install [Microsoft's runtime](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist).++Voice cloning is included, and no Hugging Face login is needed. It also pulls the small ONNX+runtime, so the [lightweight models](docs/onnx-models.md) work from the same install.### Basic usage@@ -132,12 +134,12 @@ sf.write("output.wav", audio, m.sample_rate)```> To run Kitten-TTS 2 on a CPU, please refer to [Running on CPU](#running-on-cpu)-`m.available_voices` lists all 47 built-in voices, described in+`m.available_voices` lists all 115 built-in voices, described in[voices and expression](docs/voices-and-expression.md). Bella, Jasper, Luna, Bruno, Rosie, Hugo,Kiki and Leo are the same speakers as in KittenTTS 0.8, so code written against the ONNX modelskeeps working.-The weights come in two sizes. The default is 947 MiB and lossless; `weights="emb4"` is 506 MiB+The weights come in two sizes. The default is 954 MB and lossless; `weights="emb4"` is 492 MBbecause it quantises the token embedding, which costs a little quality. Only the one you ask foris downloaded.@@ -234,16 +236,15 @@ See the [MLX guide](docs/mlx.md) for benchmarks and the full details.## Running with vLLM-For GPU inference with vLLM on Linux and an NVIDIA CUDA GPU with compute capability-8.0 or newer (Ampere or later, for bfloat16), install the optional backend. GPUs with compute-capability 7.5 can use a float16 fallback that is supported but not the optimal path-([vLLM guide](docs/vllm.md#older-gpus-compute-capability-75)).+For GPU inference on Linux or WSL2, install the optional backend. The NVIDIA install below+requires driver 580 or newer, a C compiler and Python development headers. For older drivers,+AMD GPUs and hardware compatibility, see the [vLLM guide](docs/vllm.md).```bashpip install "kittenml[vllm]"```-Select `backend="vllm"`:+Save this as `vllm_hello.py` and run `python vllm_hello.py`:```pythonfrom kittenml import KittenTTS@@ -251,19 +252,17 @@ from kittenml import KittenTTSdef main():m = KittenTTS("KittenML/kitten-tts-2", backend="vllm",vllm_options={"quantization": "w4a16"})- m.generate_to_file("Hello there.", "output.wav", voice="Bruno")- print("Saved output.wav")+ m.generate_to_file("Hello there.", "vllm_output.wav", voice="Bruno")+ print("Saved vllm_output.wav")if __name__ == "__main__":main()```-Keep the main guard when running a script: vLLM starts a worker process. The same-voices, decoders, weight choices and generation arguments apply. The example-uses 4-bit language-model weights (`"quantization": "w4a16"`): the same weights, exactly, in about-2 GB less GPU memory, and faster for single requests. Leave out `vllm_options` to run in bf16; see-[4-bit weights](docs/vllm.md#4-bit-weights). See the-[vLLM guide](docs/vllm.md) for memory settings and benchmarks.+Keep the main guard: vLLM starts a worker process. The first start downloads weights and compiles+kernels. The example uses [4-bit weights](docs/vllm.md#4-bit-weights); settings adjust automatically+on [small GPUs](docs/vllm.md#small-gpus). See the [vLLM guide](docs/vllm.md) for options and+[benchmarks](docs/vllm.md#benchmarks) for performance.## Long text and streaming@@ -283,9 +282,7 @@ for chunk in m.generate_stream(long_text, voice="Luna"):It takes the same arguments as `generate`, so `reference=` streams a cloned voice too.Streaming is **chunk-level, not token-level**: a chunk is generated and vocoded in full before it-is yielded, so the first chunk still costs its own generation time. On an A100, a 936-character-passage yielded its first 21 s of audio after 17 s and finished 54 s of audio in 42 s of wall-clock -- so playback keeps ahead of generation, but there is a real initial delay.+is yielded, so the first chunk still costs its own generation time.Two consequences worth knowing:@@ -302,7 +299,7 @@ Two consequences worth knowing:| | ||---|---|| [API reference](docs/api.md) | Every argument to `generate`, streaming, and the advanced knobs |-| [Voices and expression](docs/voices-and-expression.md) | The 47 voices, emotion and vocal-event tags, the ten languages |+| [Voices and expression](docs/voices-and-expression.md) | The built-in voices, languages, emotion and vocal-event tags || [Decoders](docs/decoders.md) | How audio is decoded, and the smaller quantised decoders || [Text normalization](docs/text-normalization.md) | How written text becomes spoken text || [Architecture](docs/architecture.md) | What the model is, package layout, vendored components |@@ -315,7 +312,7 @@ Two consequences worth knowing:**KittenTTS 2**- **Operating system:** Linux, Windows or Mac-- **Python:** 3.9 or later+- **Python:** 3.10 or laterA virtual environment (conda, venv, or similar) is recommended to avoid dependency conflicts.diff --git a/docs/README.md b/docs/README.mdindex 04fcf58..496fc0c 100644--- a/docs/README.md+++ b/docs/README.md@@ -5,10 +5,10 @@ Fuller detail than the [project README](../README.md), which covers getting star| | ||---|---|| [api.md](api.md) | The KittenTTS 2 API: every argument to `generate`, streaming, and the advanced knobs |-| [voices-and-expression.md](voices-and-expression.md) | The 47 built-in voices, the emotion and vocal-event tags, the ten languages |+| [voices-and-expression.md](voices-and-expression.md) | The built-in voices and their languages, the emotion and vocal-event tags || [decoders.md](decoders.md) | How audio is decoded, and the smaller quantised decoders || [mlx.md](mlx.md) | Optional Apple-silicon GPU inference with MLX |-| [vllm.md](vllm.md) | Optional NVIDIA GPU inference with vLLM |+| [vllm.md](vllm.md) | Optional GPU inference with vLLM on NVIDIA and AMD Radeon GPUs || [docker.md](docker.md) | A basic OpenAI-compatible speech API, with voice cloning, in a container || [text-normalization.md](text-normalization.md) | How written text becomes spoken text || [architecture.md](architecture.md) | What the model is, package layout, vendored components |diff --git a/docs/docker.md b/docs/docker.mdindex 6c36171..c5aa0d8 100644--- a/docs/docker.md+++ b/docs/docker.md@@ -4,14 +4,31 @@ The image runs a basic OpenAI-compatible speech API on one NVIDIA GPU: speech ascomplete file or streamed, and voice cloning. Its routes follow the[hosted KittenML API](https://docs.kittenml.com/tts/generate-speech).-Use a Linux host with Docker, an NVIDIA GPU and the-[NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html).-The host driver must meet the [vLLM GPU requirements](https://docs.vllm.ai/en/v0.31.0/getting_started/installation/gpu/).+## Requirements++- Linux with Git, [Docker](https://docs.docker.com/engine/install/) and the+ [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html).+- An NVIDIA GPU with compute capability 7.5 or newer and at least 6 GB of VRAM.+ RTX 20 / GTX 16 use rounded float16: [supported, not optimal](vllm.md#older-gpus-rtx-20-and-gtx-16-series).+- NVIDIA driver 580 or newer for the image's CUDA 13.0 runtime.+- About 25 GB of free disk space for the image and cached models.++For AMD GPUs or V100, use the separate [AMD](vllm.md#amd-gpus-rocm) or+[V100](vllm.md#v100-cuda-126-source-build) instructions; this image does not support them.++## Set up the host++Check whether Docker can already use the GPU:++```sh+docker run --rm --gpus all ubuntu:24.04 nvidia-smi+```++If this fails, complete the Docker and NVIDIA Container Toolkit setup linked above, then retry.## Start the server-Build the image from the root of a KittenTTS checkout. The final `.` is that-directory, which the build reads the package from:+Clone the repository and build the image:```shgit clone https://github.com/KittenML/KittenTTS.git@@ -22,12 +39,18 @@ docker build -f kittenml/kittentts2/docker/Dockerfile -t kittenml .Then start the server, from any directory:```sh-docker run --rm --gpus all --ipc=host -p 8000:8000 -v kittenml-cache:/cache kittenml+docker run --rm --gpus all --ipc=host -p 8000:8000 -v kittenml-cache:/cache \+ -e KITTENML_VLLM_OPTIONS='{"quantization": "w4a16"}' \+ kittenml```+The `-e` line selects [4-bit language-model weights](vllm.md#4-bit-weights).+For bf16 on RTX 30 or newer with more than 8 GB, omit that line. On smaller cards,+4-bit is selected automatically. Put any other [options](#options) in the same JSON.+The first start downloads the model and compiles GPU kernels, which takes a few-minutes. The named volume keeps both, so later starts are faster. The server is-ready when it prints `Ready`. Model files are not included in the image.+minutes. The named volume keeps both, so later starts are faster. When the server prints+`Ready`, use a second terminal for the requests below.## Generate speech@@ -43,9 +66,13 @@ curl http://localhost:8000/v1/audio/speech \sentence chunk is generated; `"stream_format": "sse"` sends Base64`speech.audio.delta` events and a final `speech.audio.done`. `response_format` is`mp3` (the default), `wav`, `pcm`, `flac` or `opus`; `flac` and `opus` are sent once-complete. `GET /v1/voices` lists the 47 built-in voices.+complete. `GET /v1/voices` lists the built-in voices (115 in the current model) and your+saved ones.-The OpenAI SDK works with any API key:+The OpenAI SDK works with any API key. Install it into a virtual environment+(on Ubuntu: `sudo apt-get install -y python3-venv`, then `python3 -m venv ~/openai-env`,+`source ~/openai-env/bin/activate`, `pip install openai`), save this as `openai_speech.py` and+run `python openai_speech.py`:```pythonfrom openai import OpenAI@@ -57,9 +84,23 @@ with client.audio.speech.with_streaming_response.create(response.stream_to_file("speech.mp3")```+It prints nothing; when it returns, `speech.mp3` is in the current directory.+## Clone a voice-Upload 2-30 seconds of one speaker as `reference_audio` to clone it for one request:+Upload 5-30 seconds of one speaker as `reference_audio` to clone it for one request, as with+the Python package (the server refuses clips shorter than 2 or longer than 30 seconds). To try+it without a recording, make `reference.wav` with a built-in voice first:++```sh+curl http://localhost:8000/v1/audio/speech \+ -H "Content-Type: application/json" \+ -d '{"model": "kitten-tts-2-latest", "voice": "Luna", "response_format": "wav", "stream": false,+ "input": "I am recording this short clip so that my voice can be cloned. It only needs a few seconds of clear speech."}' \+ --output reference.wav+```++Then clone it:```shcurl http://localhost:8000/v1/audio/speech \@@ -70,7 +111,10 @@ curl http://localhost:8000/v1/audio/speech \--output cloned.wav```-Or save the voice once and reuse its ID as `"voice": {"id": "voice_..."}`:+Whisper transcribes the clip automatically and runs on the CPU if GPU memory is low.+For faster cloning, add `-F reference_transcript="..."` with the exact words spoken to skip it.++Or save the voice once:```shcurl http://localhost:8000/v1/audio/voices \@@ -78,10 +122,30 @@ curl http://localhost:8000/v1/audio/voices \```-Saved voices are kept in the cache volume and deleted with-`DELETE /v1/audio/voices/{voice_id}`. The clip is transcribed with Whisper, which-needs more GPU memory; add `-F reference_transcript="..."` with the exact words-spoken to skip it.+It prints the new voice's `id`, such as `voice_3f2a...`. Use it as `"voice": {"id": "..."}`;+replace `VOICE_ID` below with that id:++```sh+curl http://localhost:8000/v1/audio/speech \+ -H "Content-Type: application/json" \+ -d '{"model": "kitten-tts-2-latest", "input": "Hello again.",+ "voice": {"id": "VOICE_ID"}, "response_format": "wav", "stream": false}' \+ --output saved.wav+```++Saved voices are kept in the cache volume. Delete one with:++```sh+curl -X DELETE http://localhost:8000/v1/audio/voices/VOICE_ID+```++It prints `{"id":"voice_...","object":"audio.voice","deleted":true}`.++## GPUs with 8 GB or less++Settings adjust automatically to available memory; explicit options are preserved.+Limited memory can reduce concurrency and the maximum request length. See+[Small GPUs](vllm.md#small-gpus) for requirements and tuning.## Options@@ -90,15 +154,21 @@ Pass these with `-e`:| Variable | Default | Meaning ||---|---|---|| `KITTENML_BACKEND` | `vllm` | `torch` uses the PyTorch backend |-| `KITTENML_VLLM_OPTIONS` | | `vllm_options` as JSON, e.g. `{"gpu_memory_utilization": 0.7}` on an 8 GB GPU |+| `KITTENML_VLLM_OPTIONS` | | `vllm_options` as JSON, e.g. `{"quantization": "w4a16"}`; see [Options](vllm.md#options) |++4-bit weights leave more room for vLLM's cache. To reduce its reserved GPU memory,+also set `gpu_memory_utilization` in the same JSON.The server has no authentication, so do not expose its port publicly. Unlike thehosted API, it supports only `speed` 1.0, uses the voice names from `/v1/voices`,and has no consent resources.-To run your own script instead, run this from the directory that contains it:+To run the [README's `vllm_hello.py`](../README.md#running-with-vllm), stop the server with+Ctrl+C to free GPU memory, then run this from the folder containing the script:```shdocker run --rm --gpus all --ipc=host -v kittenml-cache:/cache -v "$PWD:/workspace" \- kittenml python my_script.py+ kittenml python vllm_hello.py```++`$PWD:/workspace` mounts the current folder into the container; `vllm_output.wav` is saved there.diff --git a/docs/vllm.md b/docs/vllm.mdindex 2748932..b9c32c4 100644--- a/docs/vllm.md+++ b/docs/vllm.md@@ -1,116 +1,204 @@# Running with vLLM-The optional `vllm` backend runs KittenTTS 2's language model with vLLM 0.31.0 on an NVIDIA GPU;-audio decoding, voice cloning and text preparation stay the same. It needs Linux and a GPU with-compute capability 8.0 or newer (Ampere or later). GPUs with compute capability 7.5 can use a-float16 fallback that is supported but not the optimal path-([Older GPUs](#older-gpus-compute-capability-75)); older GPUs are refused before any download.--Install and select it as shown in the [README](../README.md#running-with-vllm). That install gets-CUDA 13.0 builds of vLLM and PyTorch, which need a driver for CUDA 13.0-([GPU requirements](https://docs.vllm.ai/en/v0.31.0/getting_started/installation/gpu/)). If-`nvidia-smi` reports a lower CUDA version, install the CUDA 12.9 builds with-[uv](https://docs.astral.sh/uv/) instead (checked with driver 570.195, which reports CUDA 12.8):+The optional `vllm` backend runs KittenTTS 2's language model on the GPU. Voices, cloning,+expression controls and audio decoding use the same API. These instructions use vLLM 0.31.0.-```bash-curl -LO https://github.com/vllm-project/vllm/releases/download/v0.31.0/vllm-0.31.0+cu129-cp38-abi3-manylinux_2_28_x86_64.whl-uv pip install --torch-backend cu129 "kittenml[vllm]" ./vllm-0.31.0+cu129-cp38-abi3-manylinux_2_28_x86_64.whl-```+Use the [README example](../README.md#running-with-vllm) on Linux or NVIDIA WSL2 with+NVIDIA driver 580 or newer, compute capability 7.5 or newer and at least 6 GB of VRAM.+vLLM also needs a C compiler and Python development headers+(`gcc` and `python3-dev` on Ubuntu); see its [requirements](https://docs.vllm.ai/en/v0.31.0/getting_started/installation/gpu/).+For other setups, expand the relevant section below. Native Windows is not supported by vLLM.++The first start downloads weights and compiles kernels. Reuse the loaded model across requests.+See [benchmarks](#benchmarks) for performance comparisons.## Options+Pass options when constructing the model, for example `vllm_options={"max_model_len": 2048}`.+| Option | Default | What it is for ||---|---|---|-| `gpu_memory_utilization` | `0.5` | Share of the GPU's memory vLLM may use for the language model and its cache. Audio decoding needs memory outside this share. |-| `max_model_len` | `4096` | Longest request in tokens: the voice's reference prompt and the text, plus `max_new_tokens` (1000 by default). A request that does not fit raises an error. |-| `max_num_seqs` | `8` | Most requests generated at the same time. |-| `kv_cache_memory_bytes` | not set | A fixed cache size in bytes, used instead of sizing the cache from `gpu_memory_utilization`. |-| `enforce_eager` | `False` | Turns off CUDA graphs. Keep it off: with it on, 4-bit can be slower than the default bf16. |-| `quantization` | not set | `"w4a16"` for 4-bit weights; see [4-bit weights](#4-bit-weights). |-| `dtype` | `"bfloat16"` | Precision of the language model. `"float16"` is a fallback for GPUs without bfloat16; see [Older GPUs](#older-gpus-compute-capability-75). |--Pass these as `vllm_options` when constructing the model, for example-`vllm_options={"max_model_len": 2048}`; unknown option names are refused before any download. Select-the GPU with `CUDA_VISIBLE_DEVICES`; set `VLLM_LOGGING_LEVEL=INFO` before starting Python to see-routine engine logs. Long text uses the default backend's sentence chunking, and `generate_stream`-yields each audio chunk once it is complete. The same seed can give different audio across backends-and with or without 4-bit weights. Start-up is slow (see [Benchmarks](#benchmarks)), so reuse the-loaded model.--## Low GPU memory--- Reduce `max_model_len`, keeping room for the prompt plus `max_new_tokens`: a shorter context- needs a smaller cache.-- If startup reports no memory available for the cache, raise `gpu_memory_utilization`, leaving room- for audio decoding, or set `kv_cache_memory_bytes`. The cache needs 112 KiB per token; a cache of- exactly `max_model_len` tokens is rejected, so leave some margin.-- Use [4-bit weights](#4-bit-weights); the smaller `weights="packed"` download alone does not- lower GPU memory.-- Cloning without `reference_text` also loads Whisper large-v3 on the GPU to transcribe the clip;- pass `reference_text` to skip it.+| `gpu_memory_utilization` | `0.5` | Share of GPU memory for the language model and cache; leave room for audio decoding. |+| `max_model_len` | `4096` | Maximum tokens for the reference prompt, input text and generated audio together. |+| `max_num_seqs` | `8` | Maximum concurrent requests. |+| `max_num_batched_tokens` | vLLM's default | Tokens processed per step; lower values use less working memory. |+| `kv_cache_memory_bytes` | not set | Fixed cache size instead of sizing it from `gpu_memory_utilization`. |+| `enforce_eager` | `False` | Disable CUDA graphs; normally leave this off. |+| `quantization` | not set; `"w4a16"` on RTX 20 / GTX 16 | Use `"w4a16"` for 4-bit weights, or `None` for dense weights. |+| `dtype` | `"bfloat16"`; `"float16"` on compute capability 7.x | Language-model precision. `"float32"` needs more memory and cannot use 4-bit weights. |++Unknown options raise an error. Select a GPU with `CUDA_VISIBLE_DEVICES`; set+`VLLM_LOGGING_LEVEL=INFO` to show engine logs.++## Small GPUs++On GPUs with 8 GB or less, and on compute capability 7.x GPUs, KittenTTS adjusts unset options+if the defaults do not fit. It can select 4-bit weights, reduce the cache or shorten the+context, and logs the chosen settings. Explicit options are preserved; setting+`gpu_memory_utilization` or `kv_cache_memory_bytes` disables automatic fitting.++This supports 6β8 GB GPUs with enough free memory, but can limit concurrent requests and+maximum request length. If even the smallest settings do not fit, loading stops with the+required free-memory amount. 4 GB cards are insufficient for this vLLM path.++For voice cloning, pass `reference_text` to skip transcription. Otherwise Whisper uses the+CPU when GPU memory is low, which takes longer and needs additional host RAM.## 4-bit weights-Add `"quantization": "w4a16"` to `vllm_options` to use about 2 GB less GPU memory for the language-model's weights (1.29 instead of 3.24 GiB). The model's weights stay exactly the same, and measured-audio quality was the same as without it. With default settings vLLM still takes half the GPU and-gives the saved memory to its cache; to lower total use, also set `kv_cache_memory_bytes` or a lower-`gpu_memory_utilization`. It works with `weights="packed"` (the default) or `"full"`, and also-with `weights="emb4"`. That one is lossy: its embedding is stored in 4 bits (at export, perplexity-13.60 against 13.50), and it only makes the download smaller, not GPU memory, because the-embedding is expanded to bf16 on the GPU either way. `"emb4"` is not available with the float16-fallback below. KittenTTS checks that vLLM runs the 4-bit layers-with the kernel they were verified with, and refuses settings that would change it.--The biggest gain is with one request at a time: the language model ran about 1.4x faster on an RTX-PRO 6000 (96 GB) and 1.8x faster on an RTX A2000 (6 GB). With many concurrent requests the gain is-small (1.02x with 50 at once on the RTX PRO 6000). On the RTX A2000, bf16 does not start with-default `vllm_options` but 4-bit does; with `kv_cache_memory_bytes` 512 MiB and `max_num_seqs` 1 for-both, five sentences one at a time:--| RTX A2000 (6 GB) | bf16 (default) | 4-bit |-|---|---:|---:|-| Peak GPU memory, whole card | 6,116 MiB | 4,096 MiB |-| Median time per sentence | 2.65 s | 1.73 s |-| Language-model speed | 54.5 tokens/s | 97.2 tokens/s |--## Older GPUs (compute capability 7.5)--GPUs without bfloat16, such as the GeForce RTX 20 and GTX 16 series, can run the language model in-float16 instead, with or without 4-bit weights:+Set `vllm_options={"quantization": "w4a16"}` to reduce language-model weight memory.+With bf16, the weight values are preserved; float16 also rounds them. Generated audio can+differ because the kernels differ.++By default, vLLM gives the saved memory to its cache. To reduce total memory use, also lower+`gpu_memory_utilization` or set `kv_cache_memory_bytes`. The separate `weights="emb4"` option+reduces download size, not GPU memory, and cannot be used with float16.++## Older NVIDIA drivers++<details>+<summary>CUDA 12.9 installation for drivers older than 580</summary>++For GPUs with compute capability 7.5 or newer, use the CUDA 12.9 builds if your driver+supports CUDA 12 but not CUDA 13. Install [uv](https://docs.astral.sh/uv/getting-started/installation/#standalone-installer)+and the compiler prerequisites above, then open a new shell with no active Python environment:++```bash+uv venv --seed --python 3.12 ~/kitten-env-cu129+source ~/kitten-env-cu129/bin/activate+uv pip install --torch-backend cu129 "kittenml[vllm]" \+ https://github.com/vllm-project/vllm/releases/download/v0.31.0/vllm-0.31.0+cu129-cp38-abi3-manylinux_2_28_x86_64.whl+uv pip uninstall torchcodec+```++The last line removes an unused optional decoder that can conflict with this CUDA build.+Run the README's `vllm_hello.py` in this environment. Activate `~/kitten-env-cu129` again+in each new terminal.++</details>++## Older GPUs (RTX 20 and GTX 16 series)++**Supported, not optimal.** These GPUs have no native bfloat16, so KittenTTS selects rounded+float16 with 4-bit weights. Use the normal install or the older-driver instructions above;+no extra precision option is needed. Audio can differ from newer GPUs.++At least 6 GB of VRAM is needed. To use dense float16, set `{"quantization": None}`;+`{"dtype": "float32"}` is an alternative that needs more memory. GPUs below compute+capability 7.0, including GTX 10, cannot use this backend; use `device="cpu"` with the+default backend instead.++## V100 (CUDA 12.6 source build)++<details>+<summary>Build vLLM for V100</summary>++**Supported, not optimal.** V100 uses rounded float16 with dense weights. It cannot use+bfloat16 or the 4-bit kernel. The standard CUDA 12.9/13 wheels and KittenTTS Docker image+cannot run on it.++Use Linux x86_64 with Python 3.12, Git, GCC/G++ and Python development headers. Install the+[CUDA 12.6 development toolkit](https://docs.nvidia.com/cuda/archive/12.6.3/cuda-installation-guide-linux/index.html)+first; `nvcc --version` must report 12.6. Then, in a new shell:++```sh+python3 -m venv ~/kitten-env-v100+source ~/kitten-env-v100/bin/activate+python -m pip install --upgrade pip uv+nvcc --version+uv pip install --torch-backend cu126 torch==2.13.0 torchaudio==2.11.0 torchvision==0.28.0+git clone --depth 1 --branch v0.31.0 https://github.com/vllm-project/vllm.git ~/vllm-v100+cd ~/vllm-v100+uv pip install --torch-backend cu126 -r requirements/build/cuda.txt+TORCH_CUDA_ARCH_LIST=7.0 MAX_JOBS=8 NVCC_THREADS=2 VLLM_USE_PRECOMPILED_RUST=1 uv pip install --torch-backend cu126 --no-build-isolation .+uv pip install --torch-backend cu126 kittenml+uv pip uninstall torchcodec+cd ~+```++Activate `~/kitten-env-v100` in each new terminal. Save this as `v100_hello.py` and run+`python v100_hello.py`; it leaves out the README example's unsupported 4-bit option:```python-m = KittenTTS("KittenML/kitten-tts-2", backend="vllm",- vllm_options={"dtype": "float16", "quantization": "w4a16"})+from kittenml import KittenTTS+import soundfile as sf++if __name__ == "__main__":+ model = KittenTTS("KittenML/kitten-tts-2", backend="vllm")+ audio = model.generate("Hello from KittenTTS!", voice="Bruno")+ sf.write("v100_output.wav", audio, model.sample_rate)+ print("Saved v100_output.wav")+```++</details>++## AMD GPUs (ROCm)++Radeon RX 7000 (RX 7700 and up) and RX 9000 series use a separate ROCm installation.+The WSL2 application path is tested; native Linux remains untested. RX 7600 and older+Radeon GPUs are not supported by this vLLM build.++<details>+<summary>Windows 11 with WSL2</summary>++Use Ubuntu 24.04 in WSL2 with Python 3.12, a C compiler and Python development headers.+Follow [AMD's WSL2 setup](https://rocm.docs.amd.com/projects/radeon-ryzen/en/docs-7.2.1/docs/install/installrad/wsl/howto_wsl.html)+for the Windows driver, and [ROCDXG setup](https://github.com/ROCm/librocdxg/blob/v1.2.2/README.md#quickstart)+for ROCm and its WSL2 bridge. Use **ROCm 7.2.4 and librocdxg 1.2.2** with the package versions+below. Do not install `amdgpu-dkms` inside WSL2. Windows-side setup was not part of our testing.++Once `rocminfo` lists your GPU, create a fresh environment in Ubuntu:++```sh+python3 -m venv ~/kitten-env-rocm+source ~/kitten-env-rocm/bin/activate+pip install uv+uv pip install "kittenml[vllm]" --extra-index-url https://wheels.vllm.ai/rocm/0.31.0/rocm723+```++Save the README's `vllm_hello.py`. In each terminal, activate the environment and set the+WSL2 compatibility variables before running it:++```sh+source ~/kitten-env-rocm/bin/activate+export HSA_ENABLE_DXG_DETECTION=1+export ROCPROFILER_REGISTER_ENABLED=0+python vllm_hello.py+```++</details>++<details>+<summary>Native Linux (untested)</summary>++Set up the host with [AMD's Linux driver instructions](https://rocm.docs.amd.com/projects/radeon-ryzen/en/docs-7.2.1/docs/install/installrad/native_linux/install-radeon.html)+and [Docker](https://docs.docker.com/engine/install/). The GPU must be accessible through+`/dev/kfd` and `/dev/dri`. Start vLLM's ROCm container, then install KittenTTS inside it:++```bash+docker run -it --device /dev/kfd --device /dev/dri --group-add video --ipc=host \+ --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \+ -v ~/.cache/huggingface:/root/.cache/huggingface \+ --entrypoint bash vllm/vllm-openai-rocm:v0.31.0+pip install "kittenml[vllm]"```-**This is a fallback: it is supported, but it is not the optimal path.** Float16 is used only when-you ask for it; on GPUs with compute capability 8.0 or newer, keep the default (bfloat16). Only an-RTX 2070 (8 GB) was measured.--- **Precision change.** The model is published in bfloat16 and overflows in plain float16, so- KittenTTS scales its internal values down by an exact power of two. Rounding follows float16- instead of bfloat16. Given the same text and tokens, the next-token probabilities differ from- bfloat16's by 0.0085 nats on average (KL divergence; 4-bit weights in bfloat16 differ by- 0.0047). Word error rates on 36 requests (8 languages, long text, cloning) were 0.9% in- bfloat16 and 0.8-0.9% in float16. No listening test was done.-- **Not the fastest attention kernel.** vLLM's FlashAttention 2 needs compute capability 8.0, so- these GPUs use a general kernel; startup logs `Cannot use FA version 2 ...`, which is expected.- bfloat16 cannot run on these GPUs, so there is no same-card speed comparison.-- **More memory.** Float16 keeps a separate copy of the output layer: 618 MiB more than bfloat16.--| RTX 2070 (8 GB), one request at a time | float16 + 4-bit, default settings | float16, `kv_cache_memory_bytes` 1 GiB |-|---|---:|---:|-| Language-model speed | 108 tokens/s | 74 tokens/s |-| Synthesis time per second of audio | 0.30 s | 0.41 s |-| First audio when streaming (median) | 1.33 s | 1.80 s |-| Peak GPU memory, whole card | 6,574 MiB | 8,024 MiB |-| Startup with warm caches | 55 s | 46 s |--Measured with `generate()` on the same 36 texts (29 of them for streaming), one request at a time.+Use `backend="vllm"` in your script. These device flags are for native Linux, not WSL2.++</details>++## Output differences++The same seed does not guarantee identical audio across GPU types, backends or precision+settings. Cloning can also differ when CPU transcription uses a different Whisper model;+provide `reference_text` to skip that step.## Benchmarks+Times vary with hardware, settings and text; startup is excluded unless stated.++### PyTorch and vLLM+One RTX 3060 (12 GB), driver 570.195.03 (CUDA 12.8), Ubuntu 24.04, Python 3.12, nothing else on theGPU. PyTorch GPU is the default backend (PyTorch 2.14.1 CUDA 12.6 build, Transformers 5.20.2); thevLLM columns use vLLM 0.31.0 (CUDA 12.9 build, PyTorch 2.13.0, Transformers 5.17.0) with default@@ -139,3 +227,46 @@ give vLLM the same share of the card, so 4-bit gets a larger cache (37,120 token18,512); its higher whole-card peak was in the main process, which decodes the audio, not invLLM's own process. Whole-card peaks include about 374 MiB the GPU reports as used when idle. Afull repeat of every column was within -0.9% to +3.4%.++### Older NVIDIA GPUs++These modes used the same model revision and 72 requests: three voices, six texts, two seeds,+streaming and complete audio. RTF is generation time divided by audio length; lower is faster.+First audio is the median for short streaming requests. Memory is whole-card peak use.++| GPU and mode | Word error rate | Median RTF | First audio | Peak GPU memory |+|---|---:|---:|---:|---:|+| RTX 3060 12 GB, bf16 reference | 0.25% | 0.45 | 1.52 s | 10,466 MiB |+| RTX 2060 12 GB, rounded float16 | 0.25% | 0.48 | 1.60 s | 10,144 MiB |+| RTX 2060 12 GB, rounded float16 + 4-bit (chosen) | 0.25% | 0.33 | 1.15 s | 9,672 MiB |+| RTX 2060 12 GB, float32 | 0.25% | 0.79 | 2.55 s | 11,640 MiB |+| GTX 1660 Ti 6 GB, rounded float16 + 4-bit | 0.25% | 1.12 | 3.75 s | 5,608 MiB |++The float32 RTX 2060 run used `gpu_memory_utilization=0.74` and+`max_num_batched_tokens=2048`. The GTX 1660 Ti used automatic memory fitting.++| V100 32 GB mode | Word error rate | Median RTF | First audio | Peak GPU memory |+|---|---:|---:|---:|---:|+| Rounded float16 (chosen) | 0.25% | 0.25 | 0.82 s | 20,747 MiB |+| Float32 | 0.25% | 0.36 | 1.21 s | 20,953 MiB |++V100 used the CUDA 12.6 source build and default memory settings. All modes in these two+tables had eight word errors in 3,248 words, no detected dropped sentences, and no silent or+non-finite audio. These are transcription measurements; human listening remains pending.++### AMD Radeon under WSL2++Each mode used 72 requests: three voices, six texts, two seeds, streaming and complete audio.+The RX 7900 XTX and RX 9070 XT used vLLM's ROCm image under WSL2; the RX 9060 XT and RX 7800 XT+used the WSL2 Python environment. These are not native Linux results.++| GPU | bf16: seconds per second of audio | 4-bit: seconds per second of audio | Word error rate: bf16 / 4-bit |+|---|---:|---:|---:|+| RX 7900 XTX | 0.24 | 0.18 | 0.31% / 0.31% |+| RX 9070 XT | 0.28 | 0.21 | 0.31% / 0.31% |+| RX 9060 XT | 0.47 | 0.32 | 0.25% / 0.62% |+| RX 7800 XT | 0.36 | 0.26 | 0.31% / 0.31% |++No request lost words on these cards. The RX 7900 XTX was measured before the long-text+decoder fix; the RX 9070 XT includes it. Transcription scores do not establish identical+sound across GPUs or replace listening checks.diff --git a/docs/voices-and-expression.md b/docs/voices-and-expression.mdindex 1bacdee..e0b229a 100644--- a/docs/voices-and-expression.md+++ b/docs/voices-and-expression.md@@ -65,10 +65,9 @@ extend them if you want more tags protected.## Built-in voices-Forty-seven voices, listed by `model.available_voices`: thirty-eight English, plus nine named-after the [languages](#languages) below. Bella, Jasper, Luna, Bruno, Rosie, Hugo, Kiki and Leo-are the same speakers as in KittenTTS 0.8, so code written against the ONNX models keeps-working.+`model.available_voices` lists all 115 voices. The original 47 are listed below and under+[Languages](#languages). Bella, Jasper, Luna, Bruno, Rosie, Hugo, Kiki and Leo are the same+speakers as in KittenTTS 0.8, so code written against the ONNX models keeps working.| Voice | Character | | Voice | Character ||---|---|---|---|---|@@ -98,9 +97,7 @@ transcript: both go into the prompt, which is why cloning a new voice wants a tr## Languages-The model is multilingual. Its SFT mix is about 10% non-English across nine languages, and a-Hindi voice was added on top, giving ten in total. Each ships as one built-in voice, named-after its language:+The model supports 20 languages. These built-in voices are named after their language:| Voice | Language | Voice | Language ||---|---|---|---|@@ -125,7 +122,7 @@ oversight β the upstream demo carries the same caveat.One reference clip per language is a modest base, so expect these to be less robust than theEnglish voices, and quality to vary by language. Measured by transcribing generated audio back-with Whisper, all ten reproduce their prompt: German, Spanish, French, Italian, Portuguese,+with Whisper, the original ten reproduce their prompt: German, Spanish, French, Italian, Portuguese,Russian and Chinese came back verbatim; Arabic and Hindi came back with small errors.## Getting more expressive outputdiff --git a/gradio_demo.py b/gradio_demo.pyindex 45a2563..9054875 100644--- a/gradio_demo.py+++ b/gradio_demo.py@@ -3,7 +3,7 @@pip install kittenml gradiopython gradio_demo.py # then open http://localhost:7860python gradio_demo.py --share # also print a public link- python gradio_demo.py --backend vllm # NVIDIA GPU, needs pip install "kittenml[vllm]"+ python gradio_demo.py --backend vllm # GPU, after the README's vLLM installAll of the speech side goes through the `kittenml` package. This file only buildsthe interface: built-in voices, cloning from an uploaded or recorded clip, thediff --git a/pyproject.toml b/pyproject.tomlindex f34fc4f..71c8228 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"[project]name = "kittenml"-version = "0.9.6"+version = "0.9.7"description = "Text-to-speech with voice cloning and expression control, plus ultra-lightweight models that run on CPU"readme = "README.md"requires-python = ">=3.10"diff --git a/setup.py b/setup.pyindex 73f3c01..9ff2723 100644--- a/setup.py+++ b/setup.py@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:setup(name="kittenml",- version="0.9.6",+ version="0.9.7",author="KittenML",author_email="",description="Text-to-speech with voice cloning and expression control, plus ultra-lightweight models that run on CPU",