indic-tts-preprocess
A small Python library that fixes one specific but very annoying problem with open-source Indic TTS models: they cannot read numbers.
Models like ai4bharat/indic-parler-tts hallucinate badly when the input text contains raw digits. Feed them "1997 में" and you get garbled audio. Feed them "उन्नीस सौ सत्तानवे में" and it works perfectly.
This library does that conversion for you — numbers, years, dates — before the text ever reaches the tokenizer.
Install
pip install indic-tts-preprocess
No dependencies. Pure Python. Works on Python 3.8 and above.
Quick start
from indic_tts_preprocess import preprocess
# Hindi
preprocess("उनका जन्म 5 अगस्त 1997 को हुआ", "hi")
# -> "उनका जन्म पाँच अगस्त उन्नीस सौ सत्तानवे को हुआ"
# Marathi
preprocess("त्यांचा जन्म 15 ऑगस्ट 1947 रोजी झाला", "mr")
# -> "त्यांचा जन्म पंधरा ऑगस्ट एकोणीस शे सत्तेचाळीस रोजी झाला"
# English
preprocess("He was born on 15 August 1947", "en")
# -> "He was born on fifteen August nineteen forty seven"
Supported languages
| Code | Language |
|---|---|
hi |
Hindi |
mr |
Marathi |
en |
English |
If you pass an unsupported language code, the text comes back unchanged — nothing crashes.
What it handles
Date formats
| Input | Language | Output |
|---|---|---|
5 अगस्त 2004 |
hi | पाँच अगस्त दो हज़ार चार |
05/08/2004 |
hi | पाँच अगस्त दो हज़ार चार |
05-08-2004 |
hi | पाँच अगस्त दो हज़ार चार |
15 August 1947 |
en | fifteen August nineteen forty seven |
15/08/1947 |
en | fifteen August nineteen forty seven |
Standalone numbers
| Input | Language | Output |
|---|---|---|
73 |
hi | तिहत्तर |
1997 |
hi | उन्नीस सौ सत्तानवे |
2024 |
en | two thousand twenty four |
1905 |
en | nineteen oh five |
Year handling (the tricky part)
Hindi and Marathi speakers say years in the 1900s differently from how you'd read them literally:
1997→उन्नीस सौ सत्तानवे(notएक हज़ार नौ सौ सत्तानवे)
English speakers do the same:
1997→nineteen ninety seven(notone thousand nine hundred ninety seven)1905→nineteen oh five
The library handles all of these correctly.
API reference
preprocess(text, lang)
| Parameter | Type | Description |
|---|---|---|
text |
str |
The raw input text containing digits/dates |
lang |
str |
Language code: "hi", "mr", or "en" |
Returns str — the same text with all digits replaced by spoken words.
Raises TypeError if text is not a string.
Contributing
Adding a new language is straightforward:
- Create
indic_tts_preprocess/languages/yourlang.py— look athindi.pyas a template - Add a
preprocess(text)function and anum_to_words(n)function - Add the new language code in
core.py - Add tests in
tests/test_yourlang.py - Open a pull request
License
MIT
Metadata
Release files for indic-tts-preprocess 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| indic_tts_preprocess-0.1.1.tar.gz | 12.3 kB | Without provenance | Details for indic_tts_preprocess-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| indic_tts_preprocess-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for indic_tts_preprocess-0.1.1-py3-none-any.whl |
Total release size: 24.5 kB
Release files / indic_tts_preprocess-0.1.1.tar.gz
| Download URL | indic_tts_preprocess-0.1.1.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e04de0b2cbb226803ce94749d882cb7816953e14f8adfa32af8fc0da182ae21
|
|
BLAKE2b-256 checksum How to use checksums |
c10184bc0019bbec539303411eea3f0b32bdbe6d879b1ed079db914e48b64662
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / indic_tts_preprocess-0.1.1-py3-none-any.whl
| Download URL | indic_tts_preprocess-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f18726c514ce0141508cc09b442984c7fa80a94e8c9268c2428c1d5c0413c8be
|
|
BLAKE2b-256 checksum How to use checksums |
1a71f518fa1716113a307b64708ea0f2b3784285083155b342782cf43719602b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for indic-tts-preprocess 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.