Voice API (TTS)
The Dhamma.Gift voice is an open text-to-speech service: the same one that reads in the site's player and the dictionary. Anyone can call it from a browser or a server — no key, no login.
Address: https://api.dhamma.gift · CORS is open · a limit of 60 requests per minute per IP.
Read a phrase
POST /api/tts/pali with JSON:
| Field | Meaning |
|---|---|
text | the text, up to 2000 characters. Pāḷi in IAST (Evaṁ me sutaṁ), a translation in English or Russian |
voice | the voice (below); pratham by default |
rate | speed, 0.25–3; 1 is the voice's own pace (the site reads Pāḷi at 0.875) |
The answer is {"audioContent": "<base64 MP3>"} — the same shape as Google's Text-to-Speech, so a
player written for Google plays it as is. MP3, mono, 22 kHz, ~40 kbit/s; repeated requests come from a
cache.
curl -s https://api.dhamma.gift/api/tts/pali -H 'content-type: application/json' \
-d '{"text":"Evaṁ me sutaṁ.","voice":"pratham","rate":0.875}' \
| python3 -c 'import json,sys,base64; open("evam.mp3","wb").write(base64.b64decode(json.load(sys.stdin)["audioContent"]))'
const r = await fetch('https://api.dhamma.gift/api/tts/pali', {
method: 'POST', headers: { 'content-type': 'application/json' },
body: JSON.stringify({ text: 'Evaṁ me sutaṁ.', voice: 'pratham', rate: 0.875 })
});
new Audio('data:audio/mp3;base64,' + (await r.json()).audioContent).play();
Voices
voice | Language | What it is |
|---|---|---|
pratham | Pāḷi | "Pratham": Piper neural voice + our Pāḷi pronunciation rules (IAST → sounds, stress, long vowels). Default |
dg | Pāḷi | "Cūḷa DG": a voice trained on real Pāḷi readings. Beta |
priyamvada | Pāḷi | "Priyamvada": a female Piper voice with the same rules |
miles, alan, kathleen | English | Piper voices. miles is shown as "Yojanāni DG" (the default): trained on the readings of a real person. Pāḷi words and abbreviations (Ven., SN 56.11) are read properly |
puriso, dgru, irina | Russian | Piper voices. puriso (the default) is Supertonic's male voice M1 taught to Piper; dgru is "Cūḷa DG". Pāḷi in Latin script is read the Pāḷi way, Russian words with the right stress |
GET /api/tts/dg-voices gives the list as {"voices": [{"id", "lang", "label"}]} in menu order (a language's first voice is its default); GET /api/tts/health shows that the
service is up and which version of the pronunciation rules it uses. GET /api/tts/offline/pali-ipa.json
gives the rules, the engine and the voice models that DG downloads to read on the device, offline.
How Pāḷi is read: every letter is sounded, punctuation becomes pauses, …pe… is read as "peyyāla".
A whole text as one MP3
POST /api/tts/memo — the lines read one after another with pauses of any length between them (Google
stops at 10 seconds); this is what the Memo page saves.
| Field | Meaning |
|---|---|
segments | the lines, up to 200 and 20 000 characters in all |
voice, rate | as above |
delay | the pause between lines, seconds, up to 3600 |
end_delay | the pause at the end, seconds, up to 3600 |
sound | gong.mp3 or tick.mp3 at the end, or empty |
The answer is the MP3 itself (audio/mpeg): the speech itself at most 30 minutes, the whole file with its
pauses at most 180. One such request counts as ten against the per-minute limit.
Licences
- The service code and the Pāḷi rules: github.com/dhammagift/pali-tts.
pratham: weights MIT (rhasspy/piper-voices), recordings AI4Bharat IndicVoices (CC BY 4.0).dg,dgru: CC BY-NC-SA 4.0, non-commercial use only.priyamvada,alan,kathleen,irina: rhasspy/piper-voices, each under its own licence.
Also at this address
The same host serves the MCP server (/mcp) and the site's API
(/api/…), with the same texts and database as dhamma.gift.