Timing and listening

Automatic ayah marking

A reciter repeats an ayah and the highlight falls seconds behind. Our aligner matches each sound to the surah’s own text, and now starts where the ayah begins, not at the repeat.

  • Live in the app, checked
  • Publishing soon, as of

In short

In October 2026 the engine aligned 27,932 surah recordings, 6,420 hours of recitation, ayah by ayah and word by word: hours aligned, not hours checked by hand. A public audit then held one surah per recitation against its audio. In the median recitation, 90% of ayah starts sit within 62 ms of a speech onset. That is a proxy for the reciter’s voice, not hand-marked ground truth.

To see the timings at work, open a surah on app.thebayaan.com, pick a reciter and press play: the ayah being recited lights up.

What it does, and why real recordings fight back

Give the engine a recording and the surah it holds. It returns when each ayah starts and ends, and when each word does. It powers the timings in Bayaan and in Bayaan Studio.

If every file held one clean reading of one surah, that would be a tidy problem. Real files don’t. The catalogue’s longest surah recording runs 5.6 hours. A reciter opens with the isti’adha, says an ayah twice, or closes with a formula that is not in the text. A file holds a clip from the middle of a surah, or a different surah from the one on its label. Some stereo files cancel themselves out when they are mixed to mono. Nobody can check 27,932 recordings by ear, so the engine has to find its place on its own, and refuse when it can’t.

What one real recording can hold, drawn to no scale. The engine has to time the ayat and leave the rest alone.

How it works: hear the sounds, then fit them to the text

  1. The recording

    Split at its pauses into pieces the model can take. Each piece keeps its exact start time.

  2. Phonemes

    muaalem v3.2, an open Wav2Vec2-BERT CTC model of about 600 million parameters that we did not train, writes down the sounds it hears, and when it hears each one.

  3. The fit

    The sounds are lined up against the surah’s own text, written in the same phonetic alphabet. Text skipped at either end costs nothing.

  4. The times

    Each ayah and each word gets a start and an end in milliseconds, and each ayah a confidence.

Matching sounds rather than words is the point. A model that writes words has to guess at spelling and at where one word ends. The phoneme model writes what it hears, and the surah’s text is written in the same alphabet, so lining the two up is an exact problem with an exact answer: the edit distance, the fewest changes that turn one string into the other.

One change to the textbook version does the heavy lifting: the alignment is semi-global, or “fitting”. Skipping text at the start or end of the surah costs nothing, while every sound the model heard still has to be paid for. A full recitation aligns end to end, as before. A clip lands on its own ayat.

Where a clip from the middle of a surah lands

A global alignment

Deleting text costs the same anywhere, so the clip’s sounds are spread over the whole surah. Every ayah gets a time, and nearly all of them are wrong.

The engine’s fit

Text skipped before and after the clip costs nothing, so the clip lands on the ayat it holds and the rest of the surah is left alone.

Long files used to slide earlier and earlier

Before the alignment, the model’s output is cut into phoneme groups. The library that cuts it silently drops any character that fits no group, such as a stray mark from the decoder. The engine used to find each group’s time by adding up the lengths of the groups before it, so every dropped character nudged every later timestamp earlier, and the nudges added up over the length of the file. Now each group keeps its own position in the output, and each piece of a long recording keeps its exact start time, so nothing accumulates. The audit below measures what drift is left.

From ayat to words

The phonetic text records, for every phoneme, which word of its ayah it came from. Once the alignment has paired the text’s phonemes with moments in the recording, a word starts at its earliest phoneme the alignment kept and ends at its last. Words are counted as in the Uthmani text, so a pause mark standing on its own is not a word.

{
  "ayah": 1,
  "from": 3800,
  "to": 6975,
  "words": [
    [3800, 4240],
    [4240, 5000],
    [5000, 6040],
    [6040, 6975]
  ]
}
Al-⁠Fatihah, ayah 1, as one recitation’s word-timing file holds it: the ayah’s start and end, and one [start, end] pair per word, in milliseconds from the start of the recording. The bar draws the four word spans to scale.

The hard cases, before and after

Most fixes were tested with the real model on CPU, on recordings by five reciters, against reference timings from EveryAyah (four reciters) and Quran.com (one). Those references mark the pause before each ayah, so up to about 1 s of measured error is the reciter’s own onset. Each case names its own sample. They are small: read them as checks that each case is handled, not as accuracy figures, which come from the audit further down.

  1. An ayah said twice

    Reciters repeat an ayah, to dwell on it or to correct themselves. The alignment anchors the ayah to its last copy, so the highlight sat through the earlier copy and ran seconds behind.

    Now, if the stretch before that anchor holds the ayah’s opening sounds, the ayah starts there, at the earlier copy.

    Before
    13.6–22.8 s
    Now
    0.3–1.2 s

    The worst start error in each recording, across the reciters.

    Bench: recordings with ayah two said twice (ayat 1, 2, 2, 3, 4, 5) by the reciters tested, real model on CPU; the worst start error in each recording. 19 Oct 2026.

  2. A clip from the middle of a surah

    A recording holds Ayat al-Kursi and the two ayat after it, or ten ayat of Al-⁠Mulk. A global alignment squeezed the whole surah into it, so every time it gave was wrong.

    The fit above lands the clip on its own ayat and returns those, and no others.

    Before
    the whole surah, squeezed in
    Now
    exactly the ayat recited

    Mean start error at most 1.0 s.

    Bench: clips of Al-Mulk 10 to 19 and of Al-Baqarah 255 to 257 by the reciters tested, real model on CPU; the largest mean start error. 19 Oct 2026.

  3. A phone recording

    People record on phones: a narrow band, noise around them, heavy compression. We made Al-⁠Mulk phone quality, 8 kHz with added noise at 24 kbps, and aligned it again.

    The match score stayed between 0.984 and 0.994, far above the gate, and the start error moved by a fraction of a second.

    Studio audio
    0.18–0.62 s
    Phone quality
    ≤ 0.89 s

    Mean start error in each recording, across the reciters.

    Bench: Al-Mulk made phone quality (8 kHz, added noise, 24 kbps) by the reciters tested, real model on CPU; the largest mean start error. 19 Oct 2026.

  4. The wrong surah

    A file is labelled with one surah and holds another. Alignment still finds the closest match it can, and used to return confident-looking times for ayat that weren’t there.

    Now both gates must reach 0.7: the share of the surah’s text heard exactly, and the share of the recording the kept ayat explain. The second catches a clip that shares a phrase with the surah it is checked against. A clip of Al-⁠Baqarah 5, checked as Al Imran, matches 85.7% of the text of ayah 104, which ends with the same phrase, but explains 60% of the recording. The engine refuses with surah_mismatch and a sentence a person can act on.

    Old gate, 0.45
    7 of 16 let through
    Now, 0.7
    16 of 16 refused

    Recordings of the wrong surah. Right-surah recordings never scored below 0.976.

    Bench: 16 recordings checked against the wrong surah, real model on CPU. 19 Oct 2026.

    Wrong-surah recordings score far below the gate

    Match score: the share of the surah’s text heard exactly. Each row runs from its lowest score to its highest. Right-surah rows cover six kinds of recording by five reciters; 19 Oct 2026.

    • Lowest score
    • Highest score
    Old gate, 0.45: 0.450 Gate, 0.7: 0.700
    Right surah six kinds of recording
    Wrong surah 16 recordings

    Match score

    Show the numbers
    Match score and start error by kind of recording
    Recording Match score Start error
    Al-⁠Fatihah, whole surah 0.976 to 0.992 0.09 to 0.73 s
    Al-⁠Mulk, whole surah 0.989 to 0.996 0.18 to 0.62 s
    Al-⁠Mulk, phone quality 0.984 to 0.994 at most 0.89 s
    Part of a surah 0.976 to 0.997 at most 1.0 s
    Ayah 2 said twice 0.992 to 0.996 worst 0.3 to 1.2 s (13.6 to 22.8 s before the fix)
    Qaf, whole surah, one recording 0.996 0.31 s
    Wrong surah, 16 recordings 0.286 to 0.474 refused, all 16
  5. A stereo file that cancels itself

    Some files carry the left channel on the right, turned upside down. Mixed to mono, as the model needs, the two cancel to near silence, and the recording fails as the wrong surah.

    Now, when a surah fails that way and its right channel mirrors the left, the batch runner aligns it again on the left channel alone.

    Before
    refused as the wrong surah
    Now
    14 of 14 ayat

    Ayat timed at high confidence, on the left channel.

    Measured run: one phase-inverted recording of As-Saff, aligned end to end on Modal through the left-channel retry. 29 Oct 2026.

  6. Words around the recitation

    Many recordings open with the isti’adha and the basmala, and close with “sadaqa Allahu al-azim”, then talk. None of it is in the surah’s text. Around a short clip it dragged the score under the gate, and talk after the last ayah was timed as part of that ayah.

    Now the engine cuts the formulae off what it heard before aligning (Al-⁠Fatihah keeps its basmala, which is its opening ayah), and ends the last ayah where extra speech begins.

    Before
    three short clips refused, at 0.474 to 0.652
    Now
    62 right-surah cases, all 0.973 or higher

    The lowest score on either gate. Wrong-surah cases scored at most 0.6 on the recording share.

    Bench: 62 right-surah cases by four reciters, short single ayat with the isti'adha and basmala among them, real model; 28 wrong-surah cases scored at most 0.6 on the recording share. 19 Oct 2026.

When the engine refuses, it says why, with a code and a sentence a person can act on: surah_mismatch, no_speech_detected, audio_too_short, audio_too_long, audio_decode_failed or no_audio_stream.

At catalogue scale

In October 2026 the engine ran over Bayaan’s reciter catalogue on rented GPUs. The run could stop and pick up again without redoing work or writing a file twice: one lease per run, atomic writes, finished surahs skipped, and a hard cap on spend. A stereo file that failed as the wrong surah was checked for a mirrored channel and tried again on the left.

Surah recordings aligned
27,932
in the October 2026 run
Recitation aligned
6,420 hours
hours aligned, not checked by hand
Speed on one GPU
44× real time
approximate; about ten L4 GPUs at once
GPU cost per surah recording
$0.0065–0.0076
measured on the same run
Word timings live
30,165,982
99.54% of the words the text expects, 5 Nov 2026
Recitations with ayah timing
471 of 471
the live catalogue, 26 Nov 2026; 114 in May 2026, all mirrored from mp3quran.net and Quran.com
  • Measured run: the October 2026 catalogue run; speed and cost per L4 GPU container with two cores and 16 GiB. Oct 2026.
  • Counted: the public word-timing audit of 5 Nov 2026, 45,991 surah files from 472 recitations; and the live catalogue on 26 Nov 2026, 370 reciters and 471 recitations, with ayah timing for 45,997 of 45,997 surah recordings. May 2026: 114 recitations had ayah timing, mirrored from mp3quran.net and Quran.com in 12,881 surah files.
  • Not every live timing file comes from the October 2026 run: the word files cover 45,991 surah recordings, more than it aligned, and some ayah files still disagree with their word files (see below).

Checked against the audio

There is no hand-marked answer key for 45,991 files. So on 5 November 2026 a public audit held one surah per recitation, Al-⁠Mulk where there is one, against its own audio. It measures loudness in 20 ms steps, finds where speech starts after a pause (160 ms of quiet, then 60 ms of voice, within 1.5 s), and takes the gap between each ayah’s opening word and that onset. For each recitation it reports the gap that 90% of its ayah starts fall within.

How close ayah starts sit to the voice, recitation by recitation

Each bar counts recitations by the gap that 90% of their ayah starts fall within, in the audit’s 20 ms steps. 470 recitations, one surah each; an onset was found for 15,833 of 16,744 ayah starts. Measured against speech onsets: a proxy, not hand-marked ground truth. 5 Nov 2026.

  • Within 100 ms
  • Over 100 ms
40 ms or less 54
41 to 60 ms 173
61 to 80 ms 95
81 to 100 ms 71
101 to 120 ms 29
121 to 140 ms 12
141 to 160 ms 3
161 to 180 ms 2
181 to 200 ms 3
201 to 220 ms 3
221 to 240 ms 4
241 to 260 ms 2
261 to 280 ms 0
281 to 300 ms 1
Over 300 ms 18
Recitations
Show the numbers
Recitations by their 90th-percentile gap to a speech onset
Gap (90% of ayah starts within) Recitations Share
40 ms or less 54 11.5%
41 to 60 ms 173 36.8%
61 to 80 ms 95 20.2%
81 to 100 ms 71 15.1%
101 to 120 ms 29 6.2%
121 to 140 ms 12 2.6%
141 to 160 ms 3 0.6%
161 to 180 ms 2 0.4%
181 to 200 ms 3 0.6%
201 to 220 ms 3 0.6%
221 to 240 ms 4 0.9%
241 to 260 ms 2 0.4%
261 to 280 ms 0 0.0%
281 to 300 ms 1 0.2%
Over 300 ms 18 3.8%
The median recitation
62 ms
90% of its ayah starts within this of an onset
Within 100 ms
83.6%
393 of 470 recitations
Within 250 ms
95.7%
450 of 470 recitations

The gap leans early, if anything: the median offset is −20 ms, one 20 ms step before the voice. At the far end, 18 recitations have a gap over 300 ms, up to 1,110 ms.

Drift. Long files used to slide (see the fix above). The audit fits a straight line through each recitation’s offsets over time: the median slope is 2.7 ms per minute, either way, and 36 of 456 recitations slide more than 20 ms per minute. A straight line is easily pulled off course by a few missed onsets, and the audit’s code has since moved to the median of pairwise slopes. We refitted the same offsets that way: the median is 0 ms per minute, and one recitation slides more than 20 ms per minute.

Where this stops applying. It checks one surah per recitation, a median of 6.7 minutes long, so it says little about recordings that run for hours. Its step is 20 ms. It times ayah starts, not words. And a speech onset stands in for the reciter’s voice; no person marked where each ayah begins.

What still fails, in the open

The audit flags anything that looks wrong under strict thresholds and publishes every count. Under those thresholds, 28.9% of the 45,991 files carry no flag at all. The commonest flag by far is a word shorter than 200 ms: 18,657 files carry that one and nothing else.

Every flag the audit raised across 45,991 surah files, 5 Nov 2026
Flag Raised when Count Files
Ayah with no timean ayah has no start or no end an ayah has no start or no end 8,701 ayat 226
Ayah of zero lengthits end is not after its start its end is not after its start 23 ayat 19
Ayah with no word timestimed, but holds no words timed, but holds no words 23 ayat 19
Word of zero lengthit ends where it starts, or earlier it ends where it starts, or earlier 1,883 words 1,111
Very short wordunder 60 ms under 60 ms 4,069 words 250
Short wordunder 200 ms under 200 ms 249,743 words 28,499
Very long wordover 12 s, not counting an ayah’s last word over 12 s, not counting an ayah’s last word 14,654 words 4,199
Squeezed wordsthree or more in a row with the same length, 120 ms or less three or more in a row with the same length, 120 ms or less 4,497 words 280
Ayah file disagreesthe ayah file the app plays and the word file differ by more than 50 ms the ayah file the app plays and the word file differ by more than 50 ms — 8,858
Different ayatthe ayah file and the word file list different ayat the ayah file and the word file list different ayat — 1,274
Word split differsthe file splits words as Quran.com does in the three ayat where the app’s text joins two the file splits words as Quran.com does in the three ayat where the app’s text joins two — 1,173
Untimed tailthe audio runs on more than 30 s after the last timed word the audio runs on more than 30 s after the last timed word — 314
Unreadable audiothe recording’s length could not be read the recording’s length could not be read — 1
  • Every file passed the other checks: each file names its own surah; each holds every ayah of its surah; none names an ayah the text lacks; every timed ayah has as many words as the text; no two words overlap; no word strays outside its ayah; no ayah starts before the one before it ends; no gap between words inside an ayah runs past 2.5 s; and no time runs more than 1.5 s past the end of the audio.
  • Untimed ayat are 0.35% of the 2,462,780 ayat in the files, in 226 files. Of the 30,306,260 words the text expects, 30,165,982 are timed.
  • All 8,858 ayah-file disagreements sit in 78 recitations, every one of them originally sourced from mp3quran.net.
  • Counted: the public word-timing audit. 5 Nov 2026.

Built to catch them, not merged yet

A gate checks each surah’s files before they are published. On the live word files alone, 2,354 of 45,991 (5.1%) fail it. All 30 of 30 random files that pass it also pass the audio checks, and all four re-alignments that the engine rated high but that are wrong fail it. Bench: every live word-timing file, word checks without the audio. 6 Nov 2026.

A recovery pass re-aligns complete recordings that the usual fit cuts short, when a noisy decode or a surah recited twice throws it off. Re-run on 14 such files, eight now align fully, including a complete Al-⁠Baqarah that had stopped at ayah 154 of 286. The other six are still refused, rightly: a skipped passage, a spliced file, audio that is not Quran, partial passes repeated. Bench: complete recordings an identification pass found cut short or refused, re-run on their saved phonemes (no GPU). 23 Nov 2026.

Open problems

  • Live prayer audio. 57 sets of Taraweeh recordings, 6,313 surah files, sit in our library untimed: the aligner cannot yet time live prayer recordings. They are listed in the Bayaan repository.
  • Rewayat counted their own way. All 45,991 word files use Hafs ayah numbering. Recordings of other rewayat play with timing, but for a rewayah that counts its ayat differently, the numbers have to be remapped before each time lines up with its own ayah.
  • No ground truth at scale. Every accuracy figure here is a proxy or a small test: speech onsets for the catalogue, five reciters for the hard cases.

Credits

  • muaalem v3.2 (MIT): the speech model that hears the phonemes. We did not train or fine-tune it.
  • quran-transcript: the phonetic alphabet the model writes in, and the index that ties each phoneme of the text to its word, built on the Tanzil Uthmani text, Tanzil Project (CC BY 3.0), tanzil.net.
  • EveryAyah and Quran.com: the reference timings in the engine’s tests.
  • mp3quran.net, QuranicAudio and Quran.com: where the catalogue’s recordings come from, with the team’s own uploads.

The alignment, the gates, the word timing and the batch runner are our own work. Their code is not public yet.