Documentation Index
Fetch the complete documentation index at: https://mintlify.com/KittenML/KittenTTS/llms.txt
Use this file to discover all available pages before exploring further.
TextPreprocessor is a standalone preprocessing pipeline that converts raw text into a spoken form suitable for TTS synthesis. It expands numbers, currencies, abbreviations, and more, while removing elements that a speech model cannot pronounce meaningfully (URLs, HTML tags, etc.).
You can use it independently or let KittenTTS.generate() invoke it automatically by setting clean_text=True.
Constructor
Number handling
Convert integers to their spoken form.
42 → "forty-two".Convert decimal numbers to spoken form.
3.14 → "three point one four".Prefix bare decimals with a zero before expansion.
.5 → 0.5 → "zero point five".Text expansion options
Expand English contractions.
"don't" → "do not".Expand model/product name abbreviations to their spoken form.
Expand ordinal numbers.
"3rd" → "third".Expand percentage expressions.
"20%" → "twenty percent".Expand currency amounts.
"$9.99" → "nine dollars and ninety-nine cents".Expand time expressions.
"3:45 PM" → "three forty-five PM".Expand numeric ranges.
"5-10" → "five to ten".Expand measurement units.
"5kg" → "five kilograms".Expand scale suffixes.
"5M" → "five million".Expand scientific notation.
"1e6" → "one million".Expand fractions.
"1/3" → "one third".Expand decade references.
"the 80s" → "the eighties".Expand phone numbers digit-by-digit.
Expand IP addresses digit-by-digit.
Expand Roman numerals to spoken form.
"XIV" → "fourteen". Disabled by default because many uppercase abbreviations would be misidentified.Removal options
Convert all text to lowercase before processing.
Strip URLs from the text.
Strip email addresses from the text.
Strip HTML tags from the text.
Strip hashtags (e.g.,
#KittenTTS) from the text.Strip
@mentions from the text.Remove punctuation characters after all expansions have been applied.
Remove common stopwords from the text. Provide a custom set via
stopwords.Custom set of stopwords to use when
remove_stopwords=True. If None, a built-in English stopword list is used.Collapse multiple consecutive whitespace characters into a single space and strip leading/trailing whitespace.
Unicode handling
Apply Unicode NFC normalization to the text.
Strip accent marks from characters after Unicode normalization.
"café" → "cafe".Methods
process()
TextPreprocessor is also callable — pp(text) is equivalent to pp.process(text).
Usage examples
TextPreprocessor is stateless — you can reuse a single instance across many calls without any thread-safety concerns.