Add zipfa model
Browse files- README.md +66 -0
- bpe.model +3 -0
- model.int8.onnx +3 -0
- model.onnx +3 -0
- tokens.txt +52 -0
- zipfa.json +60 -0
README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- uk
|
| 5 |
+
datasets:
|
| 6 |
+
- speech-uk/cv22
|
| 7 |
+
library_name: onnx
|
| 8 |
+
pipeline_tag: automatic-speech-recognition
|
| 9 |
+
tags:
|
| 10 |
+
- forced-alignment
|
| 11 |
+
- ctc
|
| 12 |
+
- zipformer
|
| 13 |
+
- onnx
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
# zipfa Ukrainian: small CTC forced aligner (Cyrillic script)
|
| 17 |
+
|
| 18 |
+
Forced aligner for Ukrainian (Cyrillic script). Given audio and its transcript, it returns a start and end time for every word. Latin-script words in the text (names, English terms) get a shared wildcard span, or can be re-aligned with the English zipfa model as a second model.
|
| 19 |
+
|
| 20 |
+
## Training
|
| 21 |
+
|
| 22 |
+
`speech-uk/cv22` (Common Voice 22 Ukrainian, 97.5 h), 60 epochs, starting from the English zipfa encoder; export averaged over the last 15. No reference word timings exist for Ukrainian, so the time offset (0.04 s) is copied from the English model.
|
| 23 |
+
|
| 24 |
+
## Accuracy
|
| 25 |
+
|
| 26 |
+
| measure | value |
|
| 27 |
+
|---|---|
|
| 28 |
+
| junction test (200 pairs of clips joined by 0.3 s silence, 0.10 s tolerance) | 0.995 (int8: 0.995) |
|
| 29 |
+
| greedy character error rate | 0.027 (int8: 0.027) |
|
| 30 |
+
| speed, int8, 1 CPU thread | real-time factor 0.008 |
|
| 31 |
+
|
| 32 |
+
Word boundary error is not measured: no Ukrainian reference timings exist.
|
| 33 |
+
|
| 34 |
+
## Files
|
| 35 |
+
|
| 36 |
+
| file | what it is |
|
| 37 |
+
|---|---|
|
| 38 |
+
| `model.onnx` | full-precision model (47 MB) |
|
| 39 |
+
| `model.int8.onnx` | int8-quantised model (19 MB), same accuracy, faster on CPU |
|
| 40 |
+
| `tokens.txt`, `bpe.model` | the character tokenizer |
|
| 41 |
+
| `zipfa.json` | script, frame shift (20 ms) and calibrated time offset |
|
| 42 |
+
|
| 43 |
+
## Use
|
| 44 |
+
|
| 45 |
+
With the `zipfa` package (numpy + onnxruntime + kaldi-native-fbank):
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
from huggingface_hub import snapshot_download
|
| 49 |
+
from zipfa.audio import load_audio
|
| 50 |
+
from zipfa.model import ZipfaModel
|
| 51 |
+
|
| 52 |
+
model = ZipfaModel(snapshot_download("aloudreader/zipfa-ukrainian"), int8=True)
|
| 53 |
+
for w in model.align(load_audio("clip.wav"), "добрий день"):
|
| 54 |
+
print(w.word, w.start, w.end)
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
or `python -m zipfa.cli --model-dir <folder> --audio clip.wav --text "..." --int8`.
|
| 58 |
+
|
| 59 |
+
- Input: 16 kHz mono audio, up to 120 s per call. Audio over 30 s is encoded in overlapping 30 s windows, so memory stays around 600 MB natively.
|
| 60 |
+
- Output: one start and end time per word of the given text, 20 ms resolution.
|
| 61 |
+
- Words that cannot be spelled in this model's alphabet share one wildcard span; the `zipfa` package can re-align such runs with a second model (`--second-model-dir`).
|
| 62 |
+
- In the browser it runs with onnxruntime-web (WASM): about 25–35 ms for a 5 s clip with 8 threads, about 275 MB of WASM heap.
|
| 63 |
+
|
| 64 |
+
## Model
|
| 65 |
+
|
| 66 |
+
Zipformer CTC encoder (icefall), 9.7M parameters, 80-dim filterbank input, 50 output frames per second, trained with CR-CTC. Exported to ONNX with long-audio support.
|
bpe.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0ed80c7cb1e53c5670521c04775026a8b7b94253864605e4ea64d6e8d8f225d
|
| 3 |
+
size 727
|
model.int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:55ff0764e55473078beaf4db835a488c61e6f87b705c4f10ae8bdb0b58c3f5ea
|
| 3 |
+
size 19368365
|
model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:65b0696bdf771660cfa264e31f88e605b997500df4d80263a677eb49232af2f1
|
| 3 |
+
size 46968881
|
tokens.txt
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<blk> 0
|
| 2 |
+
<sos/eos> 1
|
| 3 |
+
<unk> 2
|
| 4 |
+
▁ 3
|
| 5 |
+
а 4
|
| 6 |
+
б 5
|
| 7 |
+
в 6
|
| 8 |
+
г 7
|
| 9 |
+
ґ 8
|
| 10 |
+
д 9
|
| 11 |
+
е 10
|
| 12 |
+
є 11
|
| 13 |
+
ж 12
|
| 14 |
+
з 13
|
| 15 |
+
и 14
|
| 16 |
+
і 15
|
| 17 |
+
ї 16
|
| 18 |
+
й 17
|
| 19 |
+
к 18
|
| 20 |
+
л 19
|
| 21 |
+
м 20
|
| 22 |
+
н 21
|
| 23 |
+
о 22
|
| 24 |
+
п 23
|
| 25 |
+
р 24
|
| 26 |
+
с 25
|
| 27 |
+
т 26
|
| 28 |
+
у 27
|
| 29 |
+
ф 28
|
| 30 |
+
х 29
|
| 31 |
+
ц 30
|
| 32 |
+
ч 31
|
| 33 |
+
ш 32
|
| 34 |
+
щ 33
|
| 35 |
+
ь 34
|
| 36 |
+
ю 35
|
| 37 |
+
я 36
|
| 38 |
+
ё 37
|
| 39 |
+
ъ 38
|
| 40 |
+
ы 39
|
| 41 |
+
э 40
|
| 42 |
+
ў 41
|
| 43 |
+
ђ 42
|
| 44 |
+
ј 43
|
| 45 |
+
љ 44
|
| 46 |
+
њ 45
|
| 47 |
+
ћ 46
|
| 48 |
+
џ 47
|
| 49 |
+
ѓ 48
|
| 50 |
+
ѕ 49
|
| 51 |
+
ќ 50
|
| 52 |
+
' 51
|
zipfa.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"script": "cyrillic",
|
| 3 |
+
"frame_shift": 0.02,
|
| 4 |
+
"time_offset": 0.04,
|
| 5 |
+
"prior_scale": 0.0,
|
| 6 |
+
"log_priors": [
|
| 7 |
+
-3.9512453079223633,
|
| 8 |
+
-3.9512453079223633,
|
| 9 |
+
-3.9512453079223633,
|
| 10 |
+
-3.9512453079223633,
|
| 11 |
+
-3.9512453079223633,
|
| 12 |
+
-3.9512453079223633,
|
| 13 |
+
-3.9512453079223633,
|
| 14 |
+
-3.9512453079223633,
|
| 15 |
+
-3.9512453079223633,
|
| 16 |
+
-3.9512453079223633,
|
| 17 |
+
-3.9512453079223633,
|
| 18 |
+
-3.9512453079223633,
|
| 19 |
+
-3.9512453079223633,
|
| 20 |
+
-3.9512453079223633,
|
| 21 |
+
-3.9512453079223633,
|
| 22 |
+
-3.9512453079223633,
|
| 23 |
+
-3.9512453079223633,
|
| 24 |
+
-3.9512453079223633,
|
| 25 |
+
-3.9512453079223633,
|
| 26 |
+
-3.9512453079223633,
|
| 27 |
+
-3.9512453079223633,
|
| 28 |
+
-3.9512453079223633,
|
| 29 |
+
-3.9512453079223633,
|
| 30 |
+
-3.9512453079223633,
|
| 31 |
+
-3.9512453079223633,
|
| 32 |
+
-3.9512453079223633,
|
| 33 |
+
-3.9512453079223633,
|
| 34 |
+
-3.9512453079223633,
|
| 35 |
+
-3.9512453079223633,
|
| 36 |
+
-3.9512453079223633,
|
| 37 |
+
-3.9512453079223633,
|
| 38 |
+
-3.9512453079223633,
|
| 39 |
+
-3.9512453079223633,
|
| 40 |
+
-3.9512453079223633,
|
| 41 |
+
-3.9512453079223633,
|
| 42 |
+
-3.9512453079223633,
|
| 43 |
+
-3.9512453079223633,
|
| 44 |
+
-3.9512453079223633,
|
| 45 |
+
-3.9512453079223633,
|
| 46 |
+
-3.9512453079223633,
|
| 47 |
+
-3.9512453079223633,
|
| 48 |
+
-3.9512453079223633,
|
| 49 |
+
-3.9512453079223633,
|
| 50 |
+
-3.9512453079223633,
|
| 51 |
+
-3.9512453079223633,
|
| 52 |
+
-3.9512453079223633,
|
| 53 |
+
-3.9512453079223633,
|
| 54 |
+
-3.9512453079223633,
|
| 55 |
+
-3.9512453079223633,
|
| 56 |
+
-3.9512453079223633,
|
| 57 |
+
-3.9512453079223633,
|
| 58 |
+
-3.9512453079223633
|
| 59 |
+
]
|
| 60 |
+
}
|