Downloads · 30 days
0
mZahran001/tasbeeh-kws
tasbeeh-kws is a machine learning model from mZahran001. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for onnx. The card lists the license as apache-2.0.
Two complementary on-device approaches to counting spoken dhikr (سبحان الله، الحمد لله، الله أكبر، أستغفر الله، لا إله إلا الله, plus three longer Azkar) over open-mic audio:
Downloads · 30 days
0
Access
Public
Updated Sep 14, 2026
Repo size
14.9 MB
Likes
0
Public
Click a slice to open those files.
.onnx9.8 MB · 100%
From the Hugging Face model README
Two complementary on-device approaches to counting spoken dhikr (سبحان الله، الحمد لله، الله أكبر، أستغفر الله، لا إله إلا الله, plus three longer Azkar) over open-mic audio:
dhikr_v2.onnx (recommended) — one utterance-level multi-class model (~1.5 MB): 9 classes (8 phrases + "none"). Handles any utterance length via a dynamic time axis — no fixed windows, no per-phrase heads.Pipeline: Silero VAD (app-side) segments the mic stream → each speech segment is featurized with openwakeword's frozen speech_embedding into (T, 96) frames (0.125 s/frame) → small temporal Conv1d (kernel 5) → [mean, max] pooled 256-dim → MLP → softmax over 9 classes. Count = one increment per segment whose argmax is a phrase (with a ~1 s refractory and an undo button).
Hold-out results (synthetic, source-level split; see eval_report_v2.json):
| phrase | n | [email protected] | mean prob | guided FP rate |
|---|---|---|---|---|
| subhanallah سبحان الله | 16 | 1.00 | 1.00 | 0.4% |
| alhamdulillah الحمد لله | 15 | 0.87 | 0.91 | 0.0% |
| allahuakbar الله أكبر | 16 | 0.94 | 0.93 | 0.0% |
| astaghfirullah أستغفر الله | 16 | 1.00 | 1.00 | 0.0% |
| la_ilaha_illa_allah لا إله إلا الله | 16 | 1.00 | 1.00 | 0.1% |
| la_hawla_wala_quwwata لا حول ولا قوة إلا بالله | 21 | 1.00 | 1.00 | 0.0% |
| la_ilaha_illa_allah_wahdahu لا إله إلا الله وحده… | 21 | 1.00 | 1.00 | 0.0% |
| la_ilaha_illa_anta لا إله إلا أنت سبحانك… | 21 | 1.00 | 1.00 | 0.0% |
Overall argmax accuracy 0.989; the only phrase→phrase confusions in the confusion matrix are 2 alhamdulillah + 1 allahuakbar → subhanallah; 12/1057 held-out negatives fire a phrase (1.1%). Guided mode (user picks one dhikr, app counts when its class prob ≥ 0.5) is directly read from this table.
Notably, the v2 design eliminated the v1 wide-window problem: the two long Azkar that
scored ~0.55 as fixed-window heads reach 1.00 here, because a 7-second dua is just
a longer (T, 96) sequence rather than a truncated window.
import onnxruntime as ort, numpy as np
sess = ort.InferenceSession("dhikr_v2.onnx", providers=["CPUExecutionProvider"])
# frames: (N, T, 96) raw openwakeword embedding frames for the whole utterance
probs = sess.run(None, {"input": frames.astype(np.float32)})[0] # (N, 9) softmax
Training: same TTS positives as v1 (~5k augmented samples), ~10k Common Voice Arabic negatives as class "none", temporal Conv1d + pooled MLP (the fix for a pooled-features version that confused most short phrases into alhamdulillah — mean/max pooling over time destroys word order, and سبحان الله / الحمد لله / أستغفر الله all end in الله), collapse guard, 150 epochs AdamW.
| phrase | Arabic | input frames | hold-out [email protected] | FP/hr | best threshold |
|---|---|---|---|---|---|
| subhanallah | سبحان الله | 16 (2 s) | 0.93 | 0.00 | 0.3 |
| alhamdulillah | الحمد لله | 16 (2 s) | 0.86 | 0.00 | 0.3 |
| allahuakbar | الله أكبر | 16 (2 s) | 0.93 | 0.00 | 0.3 |
| la_ilaha_illa_allah | لا إله إلا الله | 16 (2 s) | 0.93 | 0.00 | 0.3 |
| astaghfirullah | أستغفر الله | 16 (2 s) | 0.93 | 0.00 | 0.3 |
| la_hawla_wala_quwwata | لا حول ولا قوة إلا بالله | 12 (~1.5 s) | 0.87 | 0.00 | 0.5 |
| la_ilaha_illa_allah_wahdahu | لا إله إلا الله وحده لا شريك له… | 56 (~7 s) | 0.56 | 0.00 | 0.5 |
| la_ilaha_illa_anta | لا إله إلا أنت سبحانك إني كنت من الظالمين | 32 (~4 s) | 0.54 | 0.00 | 0.5 |
Rapid-tasbeeh detection (2 noisy simulated streams x 25 utterances, short heads): subhanallah 34/50, alhamdulillah 20/50, allahuakbar 24/50, la_ilaha_illa_allah 40/50, astaghfirullah 36/50.
Overlap note: the long dhikr لا إله إلا الله وحده لا شريك له… contains لا إله إلا الله as its opening — when the 56-frame head fires, count that dhikr and suppress the 16-frame head for that burst.
scripts/train_v2.py).Model.auto_train, 25k steps/phrase, with a collapse guard.scripts/train_v2.py — source-level hold-out split, audiomentations augmentation, frame-level standardization baked into the ONNX graph, dynamic-T export verified vs PyTorch.speech_embedding feature pipeline (openwakeword >= 0.6 from GitHub main).dhikr_v2.onnx — v2 utterance-level model (input: (N, T, 96) float32, any T; output: (N, 9) softmax, classes = 8 phrases + "none")eval_report_v2.json — v2 hold-out metricstasbeeh_<phrase>.onnx — 5 short v1 heads (input: (N, 16, 96) float32)dhikr_<phrase>_<frames>.onnx — 3 wide-window v1 heads (input: (N, 12|56|32, 96) float32)eval_report.json, eval_report_new.json — v1 eval reports