Blog · · 3 min read

DRAFT: not reviewed yet. Hidden from search engines and the sitemap until draft: false.

Tajweed phonemes explained: how we teach a model the difference between madd 2, 4 and 6

Most Arabic speech models write letters. For the Quran that throws away the part that matters most: how the text is recited. The written word جَآءَ does not say how long its alif is held (a madd muttasil: four or five counts in Hafs, four in the convention our units use); the rules of tajweed do. Our default model, Naml Tajweed, writes those sounds directly. This post explains the units, how they are produced for training, and an important limit they have.

Letters versus phonemes

A letter model sees "الرحمن" and learns to write ا ل ر ح م ن. But a reciter does not pronounce the lam (it assimilates into the ra, which is doubled), and the alif after the meem is a madd of two counts. A phoneme model writes what is actually heard: a hamza and fatha to start, a doubled ر, ح, م with its madd, ن.

For tracking, either works: the tracker compares the model's output with the expected text in the same form (how tracking works). For tajweed feedback, only the phoneme form can say anything useful.

The 77 units

Naml Tajweed's vocabulary has 77 units plus the CTC blank. They come from the Quran Phonetic Script of the open-source quran-transcript project (Hafs an Asim), which writes each sound with an optional count:

Unit Meaning
ب, ت, ث ... a consonant
ب2, ل2, ر2 ... the consonant doubled: a shadda
َ ُ ِ the short vowels fatha, damma, kasra
ا2, ا4, ا6 alif madd held for 2, 4 or 6 counts
ۥ2, ۥ4, ۥ6 / ۦ2, ۦ4, ۦ6 waw and ya madd of 2, 4, 6 counts
ن3, ن4, م4 noon and meem with ghunna
ں3 the hidden noon of ikhfa
۾3 the meem of ikhfa shafawi

So "ا4" is one unit, not four alifs, and a model trained on these units outputs "ا4" where the text calls for a 4-count madd muttasil. The model demo shows these units streaming, with the counts as small superscripts.

How the training text is made

For each recording in training we need its phonetic transcript. We get it by running the quran-transcript phonetizer over Tanzil's Uthmani text of the ayahs recited. The phonetizer applies the rules of Hafs: which noon becomes ikhfa before which letters, where idgham merges, which madd is 2, 4 or 6 counts in context. The model then learns to map audio to those units with the CTC loss.

Note what this means: the targets come from the text, not from listening to how long each reciter actually held each madd.

The limit: counts come from the text

Because every training target for a 4-count madd is "ا4", whatever the reciter did, the model learns "this word, here, is ا4". It does not learn to measure duration. We tested it directly: we edited recordings to shorten madds to about 2 counts, or to lengthen them, and re-ran the model. The output did not change in 99-100% of cases. The same holds for shortening a ghunna.

That is why our tajweed checker does not claim to check madd length. The units are still valuable: they make the model's output match recitation, which helps alignment, and many tajweed rules are about which sound is made rather than how long it lasts. A shadda is a doubled consonant or not; an ikhfa nasal is not a clear noon; iqlab turns noon into meem. Those the model can tell apart, and the checker reports them.

How madd length could be measured

Duration is a property of the audio over time, so it needs a measurement rather than a classification:

This is on our list. Until it is measured on real mistakes, it will not be in the product.

Using the units yourself

The unit list ships with the free model as s8l10_P8_units.json, with a 130-line JavaScript runner that streams audio through the model in a browser or in Node. See the model section for the download.