KittenTTS README

项目的 README,来自 github.com/KittenML/KittenTTS。合并为一个 markdown 文件:README.md。

Kitten-TTS

Kitten TTS

Hugging Face Demo Discord Website License

New: Hosted Kitten-TTS and Kitten-ASR API available at platform.kittenml.com

Frontier Open-source Speech Models from KittenML, in one package. Kitten-TTS turns text into speech, with models from 4 MB to 1.7B parameters. Kitten-ASR turns speech into text, and its enhanced models also transcribe how the words were said: emotion, delivery, emphasis and accent.

Model Parameters Size What it does
Text to speech Kitten-TTS 2 Pico 7M 4 MB per language 8 languages. Faster than realtime on a single smartphone CPU thread, with 40–50 MB of peak memory
Kitten-TTS 2 Nano 17M 8.8 MB per language 8 languages, with better voice quality than Pico
Kitten-TTS 2 Mini 82M 48 MB 16 languages
Kitten-TTS 2 Ternary 1.7B 492 MB World's First 1-bit TTS model. 20+ languages, zero-shot voice cloning and expression control. Realtime on CPUs and consumer GPUs
Speech to text Kitten-ASR Tiny 470M 900 MB Plain transcription
Kitten-ASR Small Enhanced 780M 1.5 GB (417 MB int4) Transcription plus emotion, delivery, emphasis, pauses, and accent
Kitten-ASR Medium Enhanced 2.0B 4.1 GB (1.1 GB int4) The same annotations from a larger model. **Highest Quality **

The enhanced ASR models write the delivery into the transcript:

The library also includes our existing lightweight V0.8 models. Both model families load through the same KittenTTS(...) constructor.

Commercial support is available. For integration assistance, custom voices, or enterprise licensing, contact us.

5325cae7-e2e1-4aad-8d53-caf93a268b36

Table of Contents

Features

Available Models

KittenTTS 2 -- speech language model:

Model Parameters Size Voices Download
kitten-tts-2 1.7B 492 MB 115 + cloning KittenML/kitten-tts-2

KittenTTS 2 nano / pico / mini -- small multilingual models: int8 or int4 ONNX for CPU, or the float32 weights in PyTorch (docs):

Model Parameters Size (int8) Size (int4) Languages Download
kitten-tts-2-mini 82M 83 MB 47 MB 16 KittenML/kitten-tts-2-mini
kitten-tts-2-nano 17M 17 MB per language 8.8 MB per language 8 KittenML/kitten-tts-2-nano
kitten-tts-2-pico 7M 8 MB per language 4 MB per language 8 KittenML/kitten-tts-2-pico
m = KittenTTS("KittenML/kitten-tts-2-nano")                    # ONNX, int8
m = KittenTTS("KittenML/kitten-tts-2-pico", weights="int4")    # ONNX, int4: 4 MB per language
audio = m.generate("Guten Morgen.", voice="Paul")              # a German voice
m = KittenTTS("KittenML/kitten-tts-2-nano", backend="torch")   # PyTorch, float32

Lightweight ONNX -- runs on CPU, no GPU required:

Model Parameters Size Download
kitten-tts-mini 80M 80 MB KittenML/kitten-tts-mini-0.8
kitten-tts-micro 40M 41 MB KittenML/kitten-tts-micro-0.8
kitten-tts-nano 15M 56 MB KittenML/kitten-tts-nano-0.8
kitten-tts-nano (int8) 15M 25 MB KittenML/kitten-tts-nano-0.8-int8

Demo

https://github.com/user-attachments/assets/c42c236b-7b7d-41d6-944b-7527a5f30626

Try it online

Try Kitten TTS directly in your browser on KittenML Platform.

Or run the Gradio demo locally: pip install kittenml gradio, then python gradio_demo.py.

Quick Start

Prerequisites

Installation

pip install kittenml

For NVIDIA GPU support, use a PyTorch CUDA build compatible with your driver. If PyTorch reports a missing Visual C++ runtime on Windows, install Microsoft's runtime.

Voice cloning is included, and no Hugging Face login is needed. It also pulls the small ONNX runtime, so the lightweight models work from the same install.

Basic usage

from kittenml import KittenTTS
import soundfile as sf

m = KittenTTS("KittenML/kitten-tts-2")

audio = m.generate("Hi! umm.. how are you, I guess?  .. uh.. nice to meet you??",
                   voice="WeatherPresenterCheerful")
sf.write("output.wav", audio, m.sample_rate)

To run Kitten-TTS 2 on a CPU, please refer to Running on CPU

m.available_voices lists all 115 built-in voices, described in voices and expression. 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.

The weights come in two sizes. The default is 954 MB and lossless; weights="emb4" is 492 MB because it quantises the token embedding, which costs a little quality. Only the one you ask for is downloaded.

m = KittenTTS("KittenML/kitten-tts-2", weights="emb4")   # half the download
# Trade stability against expressiveness
audio = m.generate("Hello, world.", voice="Matthew", preset="expressive")

# Save directly to a file
m.generate_to_file("Hello, world.", "output.wav", voice="Bruno")

Voice cloning

Pass reference= instead of voice= — same method, the recording just replaces the built-in speaker. Give it 5-30 seconds of a single speaker. The transcript is part of the prompt, but you do not have to type it; Whisper fills it in when omitted.

audio = m.generate("This is my own voice, cloned.", reference="my_voice.wav")

# Supplying the transcript skips the Whisper pass
audio = m.generate("This is my own voice.", reference="my_voice.wav",
                   reference_text="what is actually said in the clip")

The reference feeds the model by two independent routes -- a speaker embedding through the model's projection head, and the clip itself as codec tokens in the prompt -- so identity survives even when one route is weak.

Measured on the built-in voices: a generated clip scores 0.49-0.72 speaker similarity against its own reference and 0.01-0.18 against the other 37, and cloning an unseen recording scores 0.81 against that recording.

Expression controls

Beta. Emotion control steers delivery rather than guaranteeing it, and the effect varies by voice and by sentence.

audio = m.generate(
    "[joyful] We actually won the grant <laugh> I can (((hardly))) believe it!",
    voice="Kiki",
    preset="expressive",
)

A leading [emotion] tag, inline <event> tags and (((emphasis))) spans reach the model as markup rather than being spoken, and automatically enable its expression conditioning. Ten emotions and ten vocal events are recognised -- see voices and expression for the full lists and what is not covered.

Running on CPU

Kitten-TTS 2 runs on CPU out of the box — device is auto-detected — but the fastest way is kitten-tts-2-cpp, our llama.cpp fork. It reads the GGUF weights in the model repository's cpp/ directory. You can use the Python bindings too:

pip install kitten_tts_cpp
from kitten_tts_cpp import KittenTTS

model = KittenTTS("KittenML/kitten-tts-2", decoder="student_w4", threads=8)
model.generate_to_file("One day, a little girl named Lily found a needle in her room.", "hello.wav", voice="Bruno")
print(model.last_report)  # Generation timings and token IDs.

Kitten-TTS 2 C++ is in beta. Please report any issues you encounter.

Running on a Mac

On an Apple-silicon Mac, install the optional MLX backend and select it:

pip install "kittenml[mlx]"
from kittenml import KittenTTS

m = KittenTTS("KittenML/kitten-tts-2", backend="mlx")
m.generate_to_file("One day, a little girl named Lily found a needle in her room.",
                   "hello.wav", voice="Bruno")

See the MLX guide for benchmarks and the full details.

Kitten-ASR runs on the Mac GPU the same way: KittenASR("KittenML/kitten-asr-small-enhanced", backend="mlx"). See ASR with MLX.

Running with vLLM

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.

pip install "kittenml[vllm]"

Save this as vllm_hello.py and run python vllm_hello.py:

from kittenml import KittenTTS

def main():
    m = KittenTTS("KittenML/kitten-tts-2", backend="vllm",
                  vllm_options={"quantization": "w4a16"})
    m.generate_to_file("Hello there.", "vllm_output.wav", voice="Bruno")
    print("Saved vllm_output.wav")

if __name__ == "__main__":
    main()

Keep the main guard: vLLM starts a worker process. The first start downloads weights and compiles kernels. The example uses 4-bit weights; settings adjust automatically on small GPUs. See the vLLM guide for options and benchmarks for performance.

Long text and streaming

Long input is split on sentence boundaries and synthesized chunk by chunk, then joined with silence trimming and short edge fades so the seams are inaudible. This is automatic: the model is reliable on short inputs but truncates or drifts into repetition when asked for a whole script in one pass.

To start playing before the whole thing is ready, stream it:

for chunk in m.generate_stream(long_text, voice="Luna"):
    play(chunk)          # each chunk is a numpy array at m.sample_rate

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.

Two consequences worth knowing:

Kitten-ASR

Kitten-ASR transcribes audio using PyTorch and is included in the base pip install kittenml installation. It runs on CUDA when available, or on CPU; pass device="cpu" to select CPU explicitly.

For GPU batching with vLLM, install pip install 'kittenml[vllm]' and select KittenASR("KittenML/kitten-asr-tiny", backend="vllm") on Linux with a CUDA GPU. See ASR with vLLM for a complete example and engine settings.

On an Apple-silicon Mac, install pip install 'kittenml[mlx]' and pass backend="mlx" to run on the GPU, about 5x faster than the CPU (9x with quantization="int4", which also stays 4-bit in memory). See ASR with MLX.

Model Parameters Download size Output
kitten-asr-tiny 470M 900 MB Plain text
kitten-asr-small-enhanced 780M 1.5 GB Text with emotion, delivery, emphasis, and accent annotations
kitten-asr-medium-enhanced 2.0B 4.1 GB Same annotations as small-enhanced, from a larger model
from kittenml import KittenASR

asr = KittenASR("KittenML/kitten-asr-tiny")
print(asr.transcribe("speech.wav"))

# Get the detected language alongside the transcript.
result = asr.transcribe_detailed("speech.wav")[0]
print(result.language, result.text)

Inputs can be file paths, URLs, (waveform, sample_rate) tuples, or a list for batch transcription. Audio is converted to 16 kHz mono automatically, and long recordings are split into chunks before inference. Use language="English" to force a language, or context to provide names and terminology for the plain model.

The enhanced models return clean text plus annotations. Swap in KittenML/kitten-asr-medium-enhanced for the larger model; the API is the same:

asr = KittenASR("KittenML/kitten-asr-small-enhanced")
result = asr.transcribe_detailed("speech.wav")[0]
print(result.text)
print(result.emotions, result.delivery, result.accent)
print(result.word_annotations)

Both enhanced models also come in smaller int8 and int4 downloads: KittenASR("KittenML/kitten-asr-small-enhanced", quantization="int4") is a 417 MB download in place of 1.5 GB. See quantized checkpoints for sizes and accuracy.

For the enhanced models, context supplies a reference transcript. These preview checkpoints focus on English and several European languages; see the ASR guide for language coverage, batching, and long-audio options, and enriched output for the annotation format. A fuller example is in example_asr.py.

Documentation

API reference Every argument to generate, streaming, and the advanced knobs
Voices and expression The built-in voices, languages, emotion and vocal-event tags
Decoders How audio is decoded, and the smaller quantised decoders
Text normalization How written text becomes spoken text
Architecture What the model is, package layout, vendored components
Docker Run a basic OpenAI-compatible speech API, with voice cloning, in a container
Lightweight ONNX models The CPU models, 15M-80M parameters, and their API
MLX on Apple silicon The optional Mac GPU backend, and why it is faster
Kitten-ASR Speech-to-text: models, API, and long-audio handling
Enriched output Emotion, delivery, emphasis and accent from the enhanced ASR model

System Requirements

KittenTTS 2

A virtual environment (conda, venv, or similar) is recommended to avoid dependency conflicts.

Commercial Support

We offer commercial support for teams integrating Kitten TTS into their products. This includes integration assistance, custom voice development, and enterprise licensing.

Contact us or email [email protected] to discuss your requirements.

Community and Support

License

This project is licensed under the Apache License 2.0. That covers the code in this repository.

The models are licensed separately and their terms may differ. Each model repository carries its own licensing, so check the one you intend to use before relying on it — do not assume the code's license extends to the weights.

KittenTTS 2 is released under the Stellon Labs Community License

KittenTTS (KittenML/KittenTTS)

正在搜索数据库…

这是什么?Kitten TTS 是一个开源、轻量的文本转语音库,基于 ONNX 构建,使用 15M 到 80M 参数的超小模型,将文字转换为自然的语音,并且完全在 CPU 上运行。
这是独立的应用程序,还是我可以导入的 Python 库?它是一个 Python 库——你可以用 pip 安装,然后在自己的代码中通过 KittenTTS 类调用,而不是独立的应用程序。
怎样才能让它运行起来?按照 Installation 部分的说明用 pip 安装,然后用 KittenTTS(modelname) 加载模型,再调用 model.generate(text, voice, speed) 或 generatetofile() 生成音频。
运行它除了 Python 之外还需要别的东西吗?只需要 Python 3.8 或更高版本以及 pip;建议使用虚拟环境以避免依赖冲突,但不需要任何额外的硬件。
能直接用于生产环境吗?还不完全可以——该项目被标注为开发者预览版,意味着其 API 可能会在版本之间发生变化;而且 int8 nano 模型已有部分用户报告过问题。
支持哪些操作系统?Linux、macOS 和 Windows 均受支持,因为它只是一个基于 CPU 的 Python/ONNX 库。
内置了哪些语音?库中内置了八种语音:Bella、Jasper、Luna、Bruno、Rosie、Hugo、Kiki 和 Leo。
安装之前能先试用吗?可以,Hugging Face Spaces 上提供了在线演示,你可以直接在浏览器中测试。
支持英语以外的语言吗?暂时不支持——多语言 TTS 和专门的 ASR 模型都已列入路线图,但尚未发布。
模型文件有多大?模型大小从约 25 MB(int8 nano,15M 参数)到 80 MB(mini,80M 参数)不等,体积足够小,适合在边缘设备上部署。
作者
KittenML
大小
7.7 MB
星标
17.2K
时长
1年
提交 · 90 天