Skip to main content

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:

FieldMeaning
textthe text, up to 2000 characters. Pāḷi in IAST (Evaṁ me sutaṁ), a translation in English or Russian
voicethe voice (below); pratham by default
ratespeed, 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​

voiceLanguageWhat it is
prathamPāḷiPiper neural voice + our Pāḷi pronunciation rules (IAST → sounds, stress, long vowels). Beta
dgPāḷi"o Dhamma.Gift": a voice trained on real Pāḷi readings. Beta
alan, norman, kathleenEnglishPiper voices; Pāḷi words and abbreviations (Ven., SN 56.11) are read properly
ruslan, irinaRussianPiper voices; Pāḷi in Latin script is read the Pāḷi way

GET /api/tts/dg-voices gives the list as {voice: language}; GET /api/tts/health shows that the service is up and which version of the pronunciation rules it uses.

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.

FieldMeaning
segmentsthe lines, up to 200 and 20 000 characters in all
voice, rateas above
delaythe pause between lines, seconds, up to 300
end_delaythe pause at the end, seconds, up to 600
soundgong.mp3 or tick.mp3 at the end, or empty

The answer is the MP3 itself (audio/mpeg), at most 45 minutes long. One such request counts as ten against the per-minute limit.

Licences​

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.