Skip to content
Projets

À propos

Reconnaît les versets du Coran hors ligne et identifie la sourate et le verset à partir de l’audio. Anciennement nommé offline-tarteel, le projet a été rebaptisé Tilawa.

Design et médias

Comment ces chiffres sont mesurés

Progression mesurée des étoiles

in 24h
+6
in 7 days
+138
in 15 days
+404
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original

Tilawa

[!IMPORTANT] 2.0 is out. It ships the Tilawa v2 engine and models (68 MB full, 25 MB lite), which follow the reciter word by word and catch memorization mistakes as you recite: wrong, missed and extra words, and skipped passages. On 388 held-out learner clips, 91.9% of full's warnings were real mistakes and it caught 81.4% of them (lite: 93.3% / 80.0%). The API and event schema are unchanged from 1.0.

It flags memorization mistakes only for now (no tajweed or pronunciation grading yet, and fast hadr or kids' voices aren't supported).

Help us get to 1.0: recite 2–5 minutes the way you normally do at tilawa.dev/help, or try it live at tilawa.dev.

Offline, streaming Quran recitation engine. It follows a reciter word by word and flags memorization mistakes (wrong, omitted and added words, and skipped passages) as they happen, entirely on-device: in the browser, Node, and (soon) React Native. Audio never leaves the device.

@tilawa/core is TypeScript with no runtime dependencies. You install the ONNX Runtime for your platform as a peer dependency.

Upgrading from 1.0? Your code keeps working; the default models change. See Upgrading from 1.0 to 2.0. From 0.x, see the 0.x migration guide.

Install

npm i @tilawa/core onnxruntime-web   # browser
npm i @tilawa/core onnxruntime-node  # Node

onnxruntime-web ≥ 1.19, onnxruntime-node ≥ 1.20. Node ≥ 20.12.

In the browser, onnxruntime-web's .wasm files load from https://tilawa.dev/v2/runtime/ort/<your onnxruntime-web version>/ by default. The versions hosted there are listed in /v2/manifest.json (1.30.0 at the time of writing). For any other version, pass wasmPaths or self-host.

Browser

import { createTilawa } from "@tilawa/core/web";

// Downloads the model and the Quran reference once, then serves them from the Cache API.
const tilawa = await createTilawa({ onProgress: (p) => (bar.value = p.fraction) });

const session = tilawa.startFreeRecitation();
session.subscribe((e) => {
  if (e.type === "position" && e.observed[0]) highlight(e.observed[0].word); // { surah, ayah, word }
  if (e.type === "checker" && e.state === "confirmed") mark(e.location, e.errorClass);
});

const mic = await tilawa.listen(session); // microphone → session
// …
await mic.stop();                         // stops the tracks, then ends the session
console.log(session.mistakes());
tilawa.dispose();                         // releases the ONNX session

listen() needs a secure context (https or localhost). If it can't open the microphone it rejects with a MicrophoneError whose reason is "denied", "unavailable" or "insecure-context".

A declared passage

When the app knows what the reciter is about to read, for example a page on screen, start a memorization session for it:

const session = tilawa.startMemorization(
  { surah: 18, fromAyah: 60, toAyah: 70 },
  { confirm: { after: "next-word" } }, // confirm a mistake once the next word starts (default: 2.5 s after it)
);

The tracker then stays inside the passage, and position events carry the word the reciter should be on (expected).

Node

import { createTilawa, readWav } from "@tilawa/core/node";

const tilawa = await createTilawa(); // model cached in ~/.cache/tilawa; the reference ships in the package
const session = tilawa.startMemorization({ surah: 1, fromAyah: 1, toAyah: 7 });
session.subscribe((e) => {
  if (e.type === "checker" && e.state === "confirmed") console.log(e.errorClass, e.location);
});

const { samples, sampleRate } = await readWav("take.wav");
for (let i = 0; i < samples.length; i += 4800) session.pushAudio(samples.subarray(i, i + 4800), sampleRate);
await session.end();
console.log(session.mistakes());
await tilawa.dispose();

pushAudio takes audio at any sample rate. Calls run one at a time in call order, so a capture callback doesn't need to await them. Use modelDir to load a model directory you already have, or cacheDir to put downloads somewhere else.

Events

The event schema is versioned (v: 1). Every session sends three kinds of event:

  • capabilities comes first. It lists which error classes the model supports and which it doesn't, and carries modelVersion (the model id), modelRelease, referenceVersion, sdkVersion, modelSha256, tier and backend. Both model sets support the four memorization classes wrong_word, omitted_word, added_word and skipped_passage.
  • position: where the reciter is. observed lists candidates, best first, each with a word ({surah, ayah, word}, 1-based word index), a span and a confidence. state is acquiring, locked, ambiguous or lost. While ambiguous, hypotheses can list the competing places, best first. In memorization sessions expected is the passage word the reciter should be on.
  • checker: a possible mistake, with an id that stays the same across its states. Each one goes suspected → confirmed, or resolved (a self-correction), or uncertain (the audio was too unclear to judge). It carries errorClass, location, and the expected/observed phonemes. For a word recited more than once, occurrence can say which recitation the decision belongs to.

timeMs on position and checker events is the session audio clock: ms of 16 kHz audio delivered since the first sample. session.now() reads the same clock. ayahsRecited(events) gives the ayahs recited, in order.

Sessions

  • A session is one take. end() drains the audio and decides every open mistake. It is idempotent, and after it starts pushAudio rejects with SessionEndedError. To start again, start a new session.
  • dispose() drops a session's subscribers and buffers. tilawa.dispose() disposes every session and releases the model.
  • session.id is a uuid. session.startedAt is the wall-clock time of the first sample, and session.policy is the policy with its defaults filled in.
  • Policy: confirm ({ after: "delay", ms } or { after: "next-word" }), minConfidence (default 0.6), and countSelfCorrections (default false: resolved mistakes aren't in mistakes()).

Models and hosting

Tier Model Size Picked when
full tilawa-v2-full-c16-l128-int8@1 68 MB default
lite tilawa-v2-lite-c16-l128-int8@1 25 MB tier: "auto" on a device reporting under 4 GB of memory, on iPhone and iPad, or on another phone or tablet

By default the browser entry loads from https://tilawa.dev/v2/: models from models/<id>/<version>/model.onnx, the reference from reference/ref-v3.json, and the onnxruntime-web WASM files from runtime/ort/<version>/. These files are immutable; a new model or reference gets a new path. Downloads are checked against the sha256 in the bundled registry.

  • The 1.0 models: pass models: "v1" to load spliced-clean@1-int8 and spliced-clean-lite@1-int8 with ref-v2 from https://tilawa.dev/v1/.
  • Self-hosting: mirror that layout and pass assetBase.
  • Offline: pass reference (import @tilawa/core/assets/ref-v3.json; ref-v2.json for the 1.0 models) and a model you loaded with loadWebModel / loadNodeModel. If you serve the WASM files yourself, pass wasmPaths to loadWebModel (with your own model, createTilawa doesn't use it).

Load failures reject createTilawa with TilawaLoadError (stage: model or reference), ModelIntegrityError or ModelBudgetError. Pass signal to cancel a download.

Packages

Import What
@tilawa/core Runtime-neutral engine: createEngine, event types, loadReferenceIndex, the model registry, ayahsRecited, errors
@tilawa/core/web createTilawa, prepareMicrophone, loadWebModel, startMicrophone, cacheStorage, decodeWav
@tilawa/core/node createTilawa, loadNodeModel, loadNodeTier, fsStorage, readWav
@tilawa/core/react-native createTilawa, loadNativeModel. Experimental: not yet validated on devices. onnxruntime-react-native 1.24.3 needs four build fixes
@tilawa/core/report Opt-in problem reports (no audio is kept or sent unless the app asks)
@tilawa/core/assets/*.json ref-v3.json, ref-v2.json, phrases-v1.json

Documentation

Built with Tilawa

  • Tilawa Hifz (تلاوة): a free Quran memorization app for Android and the web. A mushaf page follows your recitation and turns itself; a daily hifz plan counts repetitions of new pages and schedules near and far revision; verses can be hidden, or the page layout removed entirely, while you recite. Runs offline. Source: 0Br19n/tilawa-web (CC BY-NC-SA 4.0).

Licence and credits

The code is MIT. The v2 models are trained on tarteel-ai/tlog (Tarteel, CC-BY-4.0); Salama1429/tarteel-ai-everyayah-Quran, azizbekphd/ikhlas_recitations, obadx/muaalem-annotated-v3, obadx/qdat and sobolev210/quran-recitation-errors (MIT); fawazahmed0/quran-audio (CC0-1.0); rabah2026/Quran-Ayah-Corpus and zaibihassan/Quranic-Recitation-Data (Apache-2.0); and consented contributor recordings (help/v1, field-dev-v2). The list is in each model's manifest (trainingSources). The 1.0 listener model is trained and evaluated on tlog (Tarteel, CC-BY) and Quranic Universal Ayahs / the QUD alignment benchmark (QUD Technologies, CC-BY). It is distilled from obadx/muaalem-model-v3_2 (MIT) and uses the quran-transcript phoneme inventory (MIT). The architecture and export follow k2-fsa icefall (Apache-2.0). The Quran text derives from Tanzil. Full notices: NOTICE.md.

This repository

  • packages/tilawa-core/: the SDK. src/engine/ and src/runtime/ are copied from the research engine at a pinned commit by scripts/sync-engine.mjs. Don't edit them by hand.
  • packages/core/, packages/sdk/: the research engine and runtime, with the lab (tools/lab.py, modal/) that measures every change. Lab history shows every experiment and the improvements over time.
  • web/: the demo at tilawa.dev.

Explorer des projets similaires

Chargement…