Skip to main content

uccharan (Python)

Phonemiser, text normaliser, transliterator and pronunciation engine for text-to-speech and speech recognition: 73 languages (English, Hindi, twenty-four more South Asian languages, twenty-nine European ones, Persian, Arabic, Hebrew, Indonesian, Malay, Swahili, Vietnamese, Korean, Mandarin, Cantonese, Tagalog, Thai, Japanese, Georgian, Kazakh, Welsh and Luxembourgish), in Rust, Python, JavaScript and C. Apache-2.0. (what it does · measurements)

  • Phonemes in the shapes Piper, Kokoro, Kitten TTS, Matcha-TTS and sherpa-onnx voices expect, compatible with the espeak-ng output those voices were trained on; an improved mode for voices you train yourself.
  • Normalise-only mode: the spoken form of numbers, money, dates and URLs for voices that read text, with spans aligned to the input.
  • Transliteration of romanised Hindi, Marathi, Bengali, Tamil, Telugu, Gujarati, Punjabi, Kannada and Malayalam into native script.
  • Pronunciation word lists, sound-alike matching of a recogniser's output against your vocabulary, and tools for training voices.
uv add uccharan          # or: uv pip install uccharan
pip install uccharan
import uccharan

uccharan.phonemize("Hello, world.")                          # 'həlˈoʊ, wˈɜːld.'
uccharan.phonemize("नमस्ते दुनिया", lang="hi")                  # 'nəmˈʌsteː dˈʊnɪjˌaː'
uccharan.phonemize("Hi there. Bye!", "en-us", "piper")       # ['hˈaɪ ðˈɛɹ.', 'bˈaɪ!']
uccharan.phonemize("Hi there.", "en-us", "sherpa-onnx")      # [[104, 712, 97, 618, …]]
uccharan.phonemize("I read it yesterday.", improved=True)    # 'aɪ ɹˈɛd ɪt jˈɛstɚdˌeɪ.'
uccharan.phonemize("I read the book.", "en-us", "kokoro")    # 'ˌI ɹˈɛd ðə bˈʊk.'  (misaki conventions, for Kokoro)
uccharan.phonemize_batch(lines, "hi")                        # all cores, GIL released

uccharan.normalize("Rs. 250 on 3/4/2024", "en-us").text      # 'two hundred fifty rupees on March fourth twenty twenty four'
uccharan.normalize("₹5 करोड़ का सौदा 10:30 बजे", "hi").text     # 'पांच करोड़ रुपये का सौदा साढ़े दस बजे'

uccharan.load_pack("xlit-hi")                                # CC BY-SA 4.0 pack, downloaded once
uccharan.transliterate("mujhe kal office jana hai", "hi").text   # 'मुझे कल office जाना है'

names = uccharan.SoundIndex(["Kothari", "Paytm"])
names.apply("send it to Coat Harry", "en-us").text           # 'send it to Kothari'

Compatible or improved mode

Compatible mode (the default) reproduces espeak-ng's phonemes, mistakes included, because that is what existing Piper, Kokoro, Kitten TTS, Matcha-TTS and sherpa-onnx voices were trained on: use it to drive those voices. Improved mode (improved=True; --improved on the command line) reads text as it is actually said: homographs in context, names, Hindi schwa deletion and nasals, Bhojpuri, Maithili, Magahi, Dogri and Bodo read as themselves, and written number words in Tamil, Kannada, Telugu and Malayalam. Use it to train new voices, and always drive a voice with the mode it was trained with. Numbers and dates are read as speech by default in both modes (normalize="natural"); normalize="espeak" copies espeak-ng number for number. What changes, and how to choose.

For code written against phonemizer:

from uccharan.compat import EspeakBackend
backend = EspeakBackend("en-us", preserve_punctuation=True, with_stress=True)
backend.phonemize(["Hello, world."], strip=True)             # ['həlˈoʊ, wˈɜːld.']

For Kokoro's KPipeline without espeak-ng, uccharan.compat.misaki has stand-ins for misaki's EspeakFallback and EspeakG2P; call install() before importing kokoro (guide).

A command-line program is installed as uccharan (uccharan -l hi -p piper "नमस्ते"). It reads standard input as UTF-8, or as UTF-16 or UTF-32 with a byte order mark (as Notepad and PowerShell write files), and always writes UTF-8.

On Windows, cmd and PowerShell 7 work as they are. Windows PowerShell 5.1 needs UTF-8 set for the pipe in both directions:

[Console]::OutputEncoding = [Text.Encoding]::UTF8   # to read uccharan's output in a pipe
$OutputEncoding = [Text.Encoding]::UTF8             # to pipe text into uccharan
"नमस्ते" | uccharan -l hi

Guides: normalise-only mode, word lists, sound-alike matching, transliteration, languages.

For training voices and checking pronunciation, uccharan.train and the uccharan-train command label a dataset (training-ready phonemes for Piper, Matcha-TTS and icefall-style recipes, a symbol table and a voice.json), choose a reading script, report phoneme and diphone coverage, and score a recogniser's output against a reference word by word (guide).

English for Kokoro uses a port of misaki with misaki 0.9.4's dictionaries; load_misaki(dir) loads another copy.

The wheel (about 2 MB) carries American English, Hindi (which Bhojpuri, Maithili and Magahi use too) and the languages read by rules alone. British English, the word tables of the other languages (de, fr, it, ur, fa …, 46 KB to 1.2 MB each) and the Kokoro English data are language packs: downloaded from the GitHub release of the same version the first time their language is used, checked against SHA-256 sums inside the wheel, and cached in ~/.cache/uccharan. When a pack cannot be had, the call raises uccharan.packs.PackError naming the pack and its URL; a language is never read without its word table.

For a machine without network access, fetch the packs elsewhere and point UCCHARAN_DATA_DIR at them:

python -m uccharan.packs --dir /opt/uccharan-data de fr ur    # or --all; no arguments lists the packs
UCCHARAN_DATA_DIR=/opt/uccharan-data UCCHARAN_OFFLINE=1 python app.py

UCCHARAN_OFFLINE=1 forbids downloads; uccharan.load_pack(path) loads a file directly. A wheel with every word table compiled in is built from the source distribution with pip install uccharan --no-binary uccharan --config-settings=build-args="--features bundle". The transliteration packs (xlit-hi, …) and the Wiktionary packs (wikipron-en-us, …) are CC BY-SA 4.0 and are fetched only when you call load_pack with their name.

Documentation, measured agreement, speed and end-to-end results: https://github.com/cB-Sigma/uccharan.

Licence

Licence: Apache-2.0. Includes data from the CMU Pronouncing Dictionary (BSD-2-Clause) and misaki (Apache-2.0); see NOTICE. The optional wikipron-* and xlit-* packs are CC BY-SA 4.0; they are separate downloads and are not part of this package.

Metadata

Release files for uccharan 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uccharan 1.2.1
File Size Uploaded Provenance Actions
uccharan-1.2.1.tar.gz 13.2 MB Without provenance Details for uccharan-1.2.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for uccharan 1.2.1
File Actions
uccharan-1.2.1-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for uccharan-1.2.1-cp39-abi3-win_amd64.whl
uccharan-1.2.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for uccharan-1.2.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
uccharan-1.2.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for uccharan-1.2.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
uccharan-1.2.1-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for uccharan-1.2.1-cp39-abi3-macosx_11_0_arm64.whl
uccharan-1.2.1-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for uccharan-1.2.1-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 25.8 MB

Release files / uccharan-1.2.1.tar.gz

Download URL uccharan-1.2.1.tar.gz
Size 13.2 MB
Tags Source
SHA-256 checksum
How to use checksums
10005e351ea20068b91ffa88096e278489e2096025769ea81b36284282445630
BLAKE2b-256 checksum
How to use checksums
0f25da38e93be06a8a6b4e4424025428fef25ed2beb45e8b1a004bed63f408de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / uccharan-1.2.1-cp39-abi3-win_amd64.whl

Download URL uccharan-1.2.1-cp39-abi3-win_amd64.whl
Size 2.5 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
960a46913a17aabcdc37cfa3ab8a4111345d99e26817a5601d571998f390c1d1
BLAKE2b-256 checksum
How to use checksums
e00ab7d5ddadffc4bb2091ec34e1c1c9426026be86da5924de18325ba7764988
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / uccharan-1.2.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL uccharan-1.2.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 2.6 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
cbab232b29896ad3010cad300831fa9b065a0ee92d7eafd306ed9236199caa40
BLAKE2b-256 checksum
How to use checksums
31a18a906ff18ae3ef4ee5c928115cc1b2d5d0c364ba84aed87d32b0b34f0fd5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / uccharan-1.2.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL uccharan-1.2.1-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 2.5 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
5fb88456258e90f32ada1c9440693102eee5c892507fa147aa473d22eb8fa0a8
BLAKE2b-256 checksum
How to use checksums
bb39e18717a404726e8d31738db1ace578456c9d9651919562dd9e1ce06f305a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / uccharan-1.2.1-cp39-abi3-macosx_11_0_arm64.whl

Download URL uccharan-1.2.1-cp39-abi3-macosx_11_0_arm64.whl
Size 2.4 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a6305deabd200dcd4089067cc6d44cc5eea559d833da14627940a01279307ded
BLAKE2b-256 checksum
How to use checksums
8b47e0d3af85818677c50e52e81cad2c7f33893393483bfa2383d33a64e55951
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / uccharan-1.2.1-cp39-abi3-macosx_10_12_x86_64.whl

Download URL uccharan-1.2.1-cp39-abi3-macosx_10_12_x86_64.whl
Size 2.6 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
3d631f101590eaf6445d2ccc70321c2589bc06521c38f5cee0369776f9916497
BLAKE2b-256 checksum
How to use checksums
599324f921a7c5607080e6083413a52507f52730d9291427e1c06fcd3cde09f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for uccharan 1.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page