Instructions to use dhammagift/pali-tts with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Piper
How to use dhammagift/pali-tts with Piper:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Pali TTS: Piper's pratham voice with Pali phonemes
There is no Pali voice in Piper or most other open TTS systems. People usually feed Pali text to a Hindi voice, and its
phonemizer rewrites Pali by Hindi rules: it drops short a, shortens long vowels, and turns ph into "f". This repository
does it differently. It keeps the open Hindi voice
hi_IN-pratham-medium unchanged and
feeds it IPA phonemes from our own deterministic Pali → IPA rules (pali_ipa.py), bypassing espeak.
The rules were tuned by ear in 55 blind listening rounds for Dhamma.Gift, where this voice reads the Pali Canon (suttas, Vinaya) on the site, offline in the app, and as daily podcasts. Among other things they cover:
- short a, kept and never deleted;
- long vowels; e and o always long;
- aspirates (ph is p + h, not f), retroflexes, ṁ before consonants and at the end of a word, ñ, ṅ, geminates;
- Pali stress (heavy penultimate);
- voice-specific fixes, e.g. ṭṭh, -iya, saṅkhāra-.
Listen
| Namo tassa bhagavato arahato sammāsambuddhassa | samples/namo-tassa.mp3 |
| SN 56.11: Evaṁ me sutaṁ … | samples/sn56.11-evam-me-sutam.mp3 |
| SN 56.11: Idaṁ kho pana, bhikkhave, dukkhaṁ ariyasaccaṁ … | samples/sn56.11-dukkha.mp3 |
Use
pip install piper-tts huggingface_hub
python speak.py "Evaṁ me sutaṁ. Ekaṁ samayaṁ bhagavā sāvatthiyaṁ viharati." out.wav
speak.py downloads pratham from rhasspy/piper-voices. It converts each sentence with to_ipa(..., full_a=True) and
then tune() (pratham's own fixes), and reads at 0.7× (Dhamma.Gift's Pali pace). Input is Pali in IAST
(ā ī ū ṁ/ṃ ṅ ñ ṭ ḍ ṇ ḷ).
The full service also reads a word standing alone (a sutta's ordinal, a rule's title) after a lead-in word and cuts the lead-in out, using the voice's own durations. That service, a browser/offline engine (onnxruntime-web + espeak WASM) and the rest live at https://github.com/dhammagift/pali-tts. A sherpa-onnx Pali lexicon is built from the same rules.
Pali words in English and Russian voices
respell.py (with stress_names.tsv) is what Dhamma.Gift uses to read Pali words inside English and Russian
translations. In English voices, Pali words (dhamma, sutta, nibbāna, devas) get our Pali phonemes instead of English
spelling rules, and references such as "SN 56.11" are read out as "Saṁyutta Nikāya 56, 11". In Russian voices
(espeak ru), Pali names in Cyrillic get the stress on the penult, as the owner hears them. The file also fixes
espeak's lost soft sign and a few wrong stresses, and reads sutta references with the numbers apart. Entry points:
en_phonemes(voice, text) and ru_phonemes(voice, text) for any Piper English or Russian voice.
Licence
- Our code and rules (
pali_ipa.py,respell.py,stress_names.tsv,speak.py): MIT. - The voice itself is not in this repository. pratham's weights are MIT, and its model card gives the dataset licence as CC BY-NC-SA 4.0, so audio you make with it is best treated as non-commercial.
- Downloads last month
- -