File size: 3,686 Bytes
226fffa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f407a3e
226fffa
 
 
 
f407a3e
 
 
 
 
 
 
 
 
 
 
 
 
226fffa
 
f407a3e
226fffa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
license: cc-by-4.0
language:
- ar
tags:
- automatic-speech-recognition
- arabic
- diacritization
- tashkeel
- speech
pipeline_tag: automatic-speech-recognition
---

# Nemo-Arabic-STT-Diacritized

An Arabic speech-to-text pipeline that produces fully diacritized (tashkeel) transcripts. It
combines two independently developed models in sequence; it is a packaged inference pipeline,
not a single jointly trained architecture.

## Pipeline

1. **Speech recognition**: [NVIDIA NeMo FastConformer Hybrid](https://huggingface.co/nvidia/stt_ar_fastconformer_hybrid_large_pcd_v1.0)
   (`stt_ar_fastconformer_hybrid_large_pcd_v1.0`) transcribes Arabic speech to plain,
   undiacritized text.
2. **Diacritization**: [CATT](https://github.com/abjadai/catt) (Character-based Arabic Tashkeel
   Transformer) adds tashkeel to the transcript.

Audio in, diacritized Arabic text out. Neither checkpoint was retrained or fine-tuned for this
repository.

## Files

| File | Description | Source |
|---|---|---|
| `stt_ar_fastconformer_hybrid_large_pcd_v1.0.nemo` | ASR checkpoint, unmodified | NVIDIA, CC-BY-4.0 |
| `best_ed_mlm_ns_epoch_178.pt` | Diacritizer checkpoint, unmodified | abjadai/CATT, Apache-2.0 |
| `diacritize.py`, `catt/` | Diacritizer inference code (vendored from CATT) | abjadai/CATT, Apache-2.0 |
| `pipeline.py` | `DiacritizedASR` โ€” loads both models once, audio in / diacritized text out in a single call | This repository |
| `server.py` | Reference FastAPI server implementing the full pipeline | This repository |

## Usage

```python
from pipeline import DiacritizedASR

model = DiacritizedASR(
    nemo_path="stt_ar_fastconformer_hybrid_large_pcd_v1.0.nemo",
    catt_ckpt="best_ed_mlm_ns_epoch_178.pt",
)
diacritized = model.transcribe("audio.wav")
```

Both models load once at construction; each `.transcribe()` call runs ASR followed immediately
by diacritization in the same process. For the two steps individually:

```python
import nemo.collections.asr as nemo_asr
from diacritize import Diacritizer

asr_model = nemo_asr.models.EncDecHybridRNNTCTCBPEModel.restore_from(
    "stt_ar_fastconformer_hybrid_large_pcd_v1.0.nemo"
)
diacritizer = Diacritizer(ckpt="best_ed_mlm_ns_epoch_178.pt")

text = asr_model.transcribe(["audio.wav"])[0].text
diacritized = diacritizer.diacritize_texts([text])[0]
```

Or run `server.py` directly for an HTTP API (`POST /transcribe`, `GET /health`).

## Example

Input audio (Arabic speech) transcribed and diacritized:

```
plain:       ุงู„ุณู„ุงู… ุนู„ูŠูƒู… ูˆุฑุญู…ุฉ ุงู„ู„ู‡ ูˆุจุฑูƒุงุชู‡ ูƒูŠู ูŠู…ูƒู†ู†ูŠ ู…ุณุงุนุฏุชูƒ ุงู„ูŠูˆู…ุŸ
diacritized: ุงู„ุณูŽู‘ู„ูŽุงู…ู ุนูŽู„ูŽูŠู’ูƒูู…ู’ ูˆูŽุฑูŽุญู’ู…ูŽุฉู ุงู„ู„ูŽู‘ู‡ู ูˆูŽุจูŽุฑูŽูƒูŽุงุชูู‡ู ูƒูŽูŠู’ููŽ ูŠูู…ู’ูƒูู†ูู†ููŠ ู…ูุณูŽุงุนูŽุฏูŽุชููƒูŽ ุงู„ู’ูŠูŽูˆู’ู…ูŽุŸ
```

## Limitations

- Diacritization quality depends on ASR transcript quality; transcription errors propagate to
  diacritization.
- CATT diacritizes using full-sentence context; very short or ambiguous transcripts may
  diacritize imperfectly.
- Developed and tested on general Modern Standard Arabic conversational speech, not evaluated on
  Quranic recitation.

## Attribution and License

- ASR model: NVIDIA, [stt_ar_fastconformer_hybrid_large_pcd_v1.0](https://huggingface.co/nvidia/stt_ar_fastconformer_hybrid_large_pcd_v1.0), CC-BY-4.0.
- Diacritizer: [abjadai/CATT](https://github.com/abjadai/catt), Apache-2.0.
- This repository (packaging and inference code) is released under CC-BY-4.0, consistent with
  the ASR model's license and compatible with CATT's Apache-2.0 terms.

Built for the [Muslim](https://huggingface.co/NightPrince) Arabic voice AI companion project.