Instructions to use altslate/indic-tts-normalizer-small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use altslate/indic-tts-normalizer-small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="altslate/indic-tts-normalizer-small")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("altslate/indic-tts-normalizer-small") model = AutoModelForSeq2SeqLM.from_pretrained("altslate/indic-tts-normalizer-small", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use altslate/indic-tts-normalizer-small with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "altslate/indic-tts-normalizer-small" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "altslate/indic-tts-normalizer-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/altslate/indic-tts-normalizer-small
- SGLang
How to use altslate/indic-tts-normalizer-small with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "altslate/indic-tts-normalizer-small" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "altslate/indic-tts-normalizer-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "altslate/indic-tts-normalizer-small" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "altslate/indic-tts-normalizer-small", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use altslate/indic-tts-normalizer-small with Docker Model Runner:
docker model run hf.co/altslate/indic-tts-normalizer-small
YAML Metadata Warning:The pipeline tag "text2text-generation" is not in the official list: text-classification, token-classification, table-question-answering, question-answering, zero-shot-classification, translation, summarization, feature-extraction, text-generation, fill-mask, sentence-similarity, text-to-speech, text-to-audio, automatic-speech-recognition, audio-to-audio, audio-classification, audio-text-to-text, voice-activity-detection, depth-estimation, image-classification, object-detection, image-segmentation, text-to-image, image-to-text, image-to-image, image-to-video, unconditional-image-generation, video-classification, reinforcement-learning, robotics, tabular-classification, tabular-regression, tabular-to-text, table-to-text, multiple-choice, text-ranking, text-retrieval, time-series-forecasting, text-to-video, image-text-to-text, image-text-to-image, image-text-to-video, visual-question-answering, document-question-answering, zero-shot-image-classification, graph-ml, mask-generation, zero-shot-object-detection, text-to-3d, image-to-3d, image-feature-extraction, video-text-to-text, keypoint-detection, visual-document-retrieval, any-to-any, video-to-video, other
Indic TTS Normalizer (small)
A 300M-parameter model that rewrites written text into spoken form for text-to-speech, in 10 Indian languages: numbers, amounts in rupees, times, dates, years, percentages, decimals, phone numbers, units, ordinals, ranges and cricket scores become words in the native script.
बिल ₹1,250.50 है, कल 4:30 PM तक जमा करें। → बिल एक हज़ार दो सौ पचास रुपये और पचास पैसे है, कल दोपहर चार बजकर तीस मिनट तक जमा करें।
(real model output; more examples below)
Try it in your browser: altslate/indic-tts-normalizer (runs locally with transformers.js; your text stays on your device).
Many Indic TTS models read digits badly or skip them (the indic-parler-tts model card lists numbers as a known issue). Put this model in front of your TTS.
Results
Three kinds of test, none used for training or for choosing settings:
- Test A (real text): 600 sentences with digits from the Dakshina Wikipedia validation split (60 per language). There is no gold spoken form, so a separate model, Qwen3.8-27B (it wrote no training data), judges each output: every number and symbol read correctly and nothing else changed. "Judge-ok" also requires that no digit or ₹ % ° is left.
- Test B (messages): up to 60 short messages per language with ₹ amounts, times, dates, phone numbers, units, ordinals, cricket scores and so on, written by the same Qwen3.8-27B. Same judge.
- Programmatic tests (exact match against rule-generated gold) on carrier sentences held out from training: one number per sentence (test-prog, 2,194), 2–3 joined sentences (test-multi, 1,000), and two numbers side by side such as
₹15,999, 128 GB(test-pair, 936).
Judge-ok on tests A and B (higher is better):
| test A (Wikipedia) | test B (messages) | |
|---|---|---|
| this model | 0.720 | 0.703 |
| rules: every number → indic-numtowords words | 0.607 | 0.388 |
| indic-tts-preprocess 0.1.1 (Hindi and Marathi only; others unchanged) | 0.157 | 0.102 |
| Qwen3-4B-Instruct, prompted | 0.068 | 0.068 |
| input unchanged | 0 | 0 |
Per language (this model / rules):
| hi | bn | ta | te | mr | gu | kn | ml | pa | ur | |
|---|---|---|---|---|---|---|---|---|---|---|
| A | .87/.80 | .90/.50 | .60/.57 | .32/.28 | .87/.60 | .82/.68 | .68/.58 | .65/.65 | .73/.75 | .77/.65 |
| B | .85/.57 | .65/.42 | .87/.48 | .32/.12 | .63/.40 | .72/.35 | .67/.30 | .72/.45 | .83/.37 | .78/.43 |
The model is better than rules in every language on test B, and on test A in all but two: Malayalam ties (0.65) and Punjabi is lower (0.73 vs 0.75). Telugu scores are low for every system: the judge rejected Telugu outputs that read years as plain numbers, which is how this model (and the rules) read them; looking at the rejected Telugu outputs, many seem correct, but we could not verify this with a native speaker.
Exact match on the programmatic tests: test-prog 0.992 (rules 0.172), test-multi 0.977, test-pair 0.997. By kind on test-prog: ordinals 0.96, phone numbers 0.98, everything else 0.99–1.00. These sentences come from the same generator as the training data, so they measure coverage of the patterns, not robustness to real text; tests A and B do that.
Examples
Hand-written sentences (not from the training generator; we used this set of 20 to find errors during development, so it is not a clean test), model output unchanged:
| input | output |
|---|---|
ఈ ఫోన్ ధర ₹15,999, 128 GB మెమరీతో వస్తుంది. |
ఈ ఫోన్ ధర పదిహేను వేల తొమ్మిది వందల తొంభై తొమ్మిది రూపాయలు, నూట ఇరవై ఎనిమిది గిగాబైట్లు మెమరీతో వస్తుంది. |
১৯৭১ সালের ১৬ ডিসেম্বর বাংলাদেশ স্বাধীন হয়। |
ঊনিশশো একাত্তর সালের ষোল ডিসেম্বর বাংলাদেশ স্বাধীন হয়। |
पेट्रोल 2.5% ने महाग झाले, आता 106.31 रुपये लिटर. |
पेट्रोल दोन पूर्णांक पाच टक्के ने महाग झाले, आता एकशे सहा पूर्णांक तीन एक रुपये लिटर. |
ಬೆಂಗಳೂರಿನಿಂದ ಮೈಸೂರಿಗೆ 145 km, ಬಸ್ ಟಿಕೆಟ್ ₹210. |
ಬೆಂಗಳೂರಿನಿಂದ ಮೈಸೂರಿಗೆ ನೂರ ನಲವತ್ತೈದು ಕಿಲೋಮೀಟರ್ಗಳು, ಬಸ್ ಟಿಕೆಟ್ ಇನ್ನೂರ ಹತ್ತು ರೂಪಾಯಿ. |
സ്വർണവില ഗ്രാമിന് ₹7,150 ആയി, ഇന്നലെ ₹7,080 ആയിരുന്നു. |
സ്വർണവില ഗ്രാമിന് ഏഴായിരത്തി നൂറ്റമ്പത് രൂപ ആയി, ഇന്നലെ ഏഴായിരത്തി എൺപത് രൂപ ആയിരുന്നു. |
મારો નંબર 98250 12345 છે, 5 વાગ્યા પછી ફોન કરજો. |
મારો નંબર નવ આઠ બે પાંચ શૂન્ય એક બે ત્રણ ચાર પાંચ છે, પાંચ વાગ્યા પછી ફોન કરજો. |
پاکستان نے 50 اوورز میں 312 رنز بنائے، 8 کھلاڑی آؤٹ ہوئے۔ |
پاکستان نے پچاس اوورز میں تین سو بارہ رنز بنائے، آٹھ کھلاڑی آؤٹ ہوئے۔ |
Usage
The input is <language code>-tn: <text>.
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("altslate/indic-tts-normalizer-small")
model = AutoModelForSeq2SeqLM.from_pretrained("altslate/indic-tts-normalizer-small")
enc = tok(["hi-tn: बिल ₹1,250.50 है, कल 4:30 PM तक जमा करें।"], return_tensors="pt")
print(tok.batch_decode(model.generate(**enc, max_new_tokens=512), skip_special_tokens=True))
Language codes: hi bn ta te mr gu kn ml pa ur. Feed one sentence at a time and set max_new_tokens to about 4× the input length in bytes; spoken forms are longer than digits.
ONNX (onnxruntime, transformers.js)
onnx/ has the encoder and decoder (with and without past, and merged) in fp32 and per-channel dynamic int8 (*_quantized.onnx, about 460 MB for the int8 set). Checked with greedy decoding in onnxruntime against PyTorch on held-out programmatic tests:
| test-prog (150 rows) exact | test-multi (100 rows) exact | outputs identical to PyTorch | |
|---|---|---|---|
| PyTorch | 0.980 | 0.970 | – |
| ONNX fp32 | 0.980 | 0.970 | 99.3% / 100% |
| ONNX int8 | 0.980 | 0.960 | 99.3% / 98% |
In our onnxruntime check on CPU, int8 took about 1 s per sentence and fp32 about 2 s. With transformers.js 4.3.2 (int8, dtype: "q8") in Node on a laptop, the snippet below took 0.1–0.7 s per sentence. Long sentences take longer: the output is generated byte by byte.
In transformers.js, ByT5 has no tokenizer.json, so encode bytes yourself (each UTF-8 byte + 3, then </s> = 1):
import { AutoModelForSeq2SeqLM, Tensor } from "@huggingface/transformers";
const model = await AutoModelForSeq2SeqLM.from_pretrained("altslate/indic-tts-normalizer-small", { dtype: "q8" });
const ids = [...new TextEncoder().encode("hi-tn: ट्रेन 3 बजे आएगी")].map((b) => b + 3).concat([1]);
const t = (a) => new Tensor("int64", BigInt64Array.from(a.map(BigInt)), [1, a.length]);
const out = await model.generate({ input_ids: t(ids), attention_mask: t(ids.map(() => 1)), max_new_tokens: 4 * ids.length + 64 });
console.log(new TextDecoder().decode(new Uint8Array(out.tolist()[0].map(Number).filter((i) => i >= 3).map((i) => i - 3))));
Training
Training and evaluation code: github.com/AltSlate-Labs/indic-chat-toolkit (src/tn/, jobs tn-*).
- Base: altslate/indic-chat-xlit-small v2 (a fine-tuned google/byt5-small, Apache-2.0), then five rounds of fine-tuning, each starting from the last (about 9 hours in total on one NVIDIA GB10 / DGX Spark; batch 32, bf16, inputs up to 768 bytes, targets up to 1,536 bytes). Each round fixed errors found in the previous one: longer inputs, years and glued suffixes in Wikipedia text, several numbers in one text, wrong spellings in the number words (below), two numbers side by side.
- Data (about 163k pairs per round): every target is generated by rules, so the spoken forms follow the rules exactly:
- Carrier sentences written by Ornith-1.5-35B-A3B (MIT), each with one typed slot (amount, time, date, year, percent, decimal, phone, quantity, ordinal, range, cricket score, number); 22k after filtering out mixed scripts, digits outside the slot, currency symbols next to the slot, unit words repeated after the slot, and cricket scores outside a cricket context. Each slot is filled 3 times with random values in a written form and its spoken form; 15% of the numeric slots get a second value after a comma, and 30k rows join 2–3 filled sentences.
- Number words: indic-numtowords (AI4Bharat, MIT) for 0–99, with corrections: its Kannada output truncates numbers such as 110 and 210 and reads 83 as 82, so Kannada and Urdu numbers from 100 up are composed here from the 0–99 words; misspellings in Punjabi (59, 73, 75, 81), Urdu (5, 23, 26–31), Bengali (88), Tamil (81, 89, 92, 98) and Marathi (हज़ार) are replaced. Month and unit names come from Unicode CLDR (via babel), plus a small hand-written lexicon of glue words (decimal-point word, rupees/paise, time and range patterns, cricket phrasing, ordinal suffixes).
- Wikipedia sentences from the Dakshina train split (CC BY-SA 4.0) with integers up to 7 digits (4-digit numbers from 1100 to 2099 read as years), plus sentences without digits that must come back unchanged. Training sentences identical to a test-A or test-B sentence were removed.
Known limitations
- Not checked by native speakers. Neither the hand-written lexicon nor our corrections to the number words were reviewed by native speakers. The lexicon follows standard news usage (Hindi
दशमलवfor the decimal point, Marathiपूर्णांक, Tamilபுள்ளி); colloquial readings ("साढ़े चार", "point", "डेढ़ सौ") are not produced. Kannada hundreds are written as separate words (ನೂರ ಹತ್ತು), not fused. - Telugu scores are low (test A 0.32, B 0.32) because the judge rejects years read as plain numbers; we believe many rejected outputs are fine but could not confirm it.
- Repeated words: when the text already has the word the model adds, it can be said twice, for example a time followed by
बजे(आठ बजकर पंद्रह मिनट बजे) or a Tamil cricket score followed byரன்கள். - Suffixes glued to numbers are kept as written, which can give unnatural forms, for example Kannada
1956ರಲ್ಲಿ→… ಐವತ್ತಾರುರಲ್ಲಿand Telugu3వ→మూడువ(instead ofమూడవ). - One reading per pattern:
12/03/2024is always day/month/year;245/6is a cricket score only in a cricket context; in Hindi, Urdu, Punjabi, Marathi, Gujarati, Bengali and Telugu, years from 1100 to 1999 are read as "nineteen eighty-four" and other years as plain numbers. Decimals are read digit by digit (106.31→ "one hundred six point three one"). - Dates are read with a cardinal day ("पच्चीस नवंबर"), not an ordinal. Ordinals can take the wrong gender (Urdu
پہلا/پہلی). - English words and acronyms (SMS, GB in running text) are left in Latin script; units after a number are spelled out.
- The carrier sentences were written by an LLM and contain typos and odd grammar. The model copies text around the numbers unchanged.
- Not covered: Sindhi and Sinhala (no number-word source), Roman-script input, numbers beyond crores.
License
Apache-2.0. The base model is Apache-2.0. Training data: Ornith outputs (MIT model), indic-numtowords (MIT), CLDR (Unicode license), Dakshina (CC BY-SA 4.0).
- Downloads last month
- 34