Add zipfa model
Browse files- README.md +67 -0
- bpe.model +3 -0
- model.int8.onnx +3 -0
- model.onnx +3 -0
- tokens.txt +31 -0
- zipfa.json +39 -0
README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
datasets:
|
| 6 |
+
- openslr/librispeech_asr
|
| 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 English: small CTC forced aligner (Latin script)
|
| 17 |
+
|
| 18 |
+
Forced aligner for English (and other text written in the 26-letter Latin alphabet, plus apostrophe). Given audio and its transcript, it returns a start and end time for every word.
|
| 19 |
+
|
| 20 |
+
## Training
|
| 21 |
+
|
| 22 |
+
LibriSpeech 960 h (CC BY 4.0), 30 epochs, export averaged over the last 10. Time offset calibrated on dev_clean (0.03 s).
|
| 23 |
+
|
| 24 |
+
## Accuracy
|
| 25 |
+
|
| 26 |
+
| measure | value |
|
| 27 |
+
|---|---|
|
| 28 |
+
| word boundary error, LibriSpeech test_clean (1,000 utterances, against Montreal Forced Aligner timings) | **46.5 ms** (int8: 46.5 ms) |
|
| 29 |
+
| boundaries within 50 ms | 68.8% |
|
| 30 |
+
| same measure, `facebook/wav2vec2-base-960h` through the same aligner | 54.6 ms |
|
| 31 |
+
| junction test (200 pairs of clips joined by 0.3 s silence, 0.10 s tolerance) | 1.000 |
|
| 32 |
+
| greedy character error rate | 0.028 |
|
| 33 |
+
| speed, int8, 1 CPU thread | real-time factor 0.008 (5 s of audio in about 40 ms) |
|
| 34 |
+
|
| 35 |
+
## Files
|
| 36 |
+
|
| 37 |
+
| file | what it is |
|
| 38 |
+
|---|---|
|
| 39 |
+
| `model.onnx` | full-precision model (47 MB) |
|
| 40 |
+
| `model.int8.onnx` | int8-quantised model (19 MB), same accuracy, faster on CPU |
|
| 41 |
+
| `tokens.txt`, `bpe.model` | the character tokenizer |
|
| 42 |
+
| `zipfa.json` | script, frame shift (20 ms) and calibrated time offset |
|
| 43 |
+
|
| 44 |
+
## Use
|
| 45 |
+
|
| 46 |
+
With the `zipfa` package (numpy + onnxruntime + kaldi-native-fbank):
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
from huggingface_hub import snapshot_download
|
| 50 |
+
from zipfa.audio import load_audio
|
| 51 |
+
from zipfa.model import ZipfaModel
|
| 52 |
+
|
| 53 |
+
model = ZipfaModel(snapshot_download("aloudreader/zipfa-english"), int8=True)
|
| 54 |
+
for w in model.align(load_audio("clip.wav"), "hello world"):
|
| 55 |
+
print(w.word, w.start, w.end)
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
or `python -m zipfa.cli --model-dir <folder> --audio clip.wav --text "..." --int8`.
|
| 59 |
+
|
| 60 |
+
- 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.
|
| 61 |
+
- Output: one start and end time per word of the given text, 20 ms resolution.
|
| 62 |
+
- 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`).
|
| 63 |
+
- 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.
|
| 64 |
+
|
| 65 |
+
## Model
|
| 66 |
+
|
| 67 |
+
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:25134f58e4d80efa39854d3340cbb9f65fd3771db74c5e2d6a8d356a45c37c98
|
| 3 |
+
size 464
|
model.int8.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a2b4653aa6c09dea18f7b9a956721fa2e013058b97c8d2c3e7e570de8e45e46c
|
| 3 |
+
size 19364248
|
model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2b1c221021bbf2bc4a77ad83a2a58bbba8bff51f5cc453a28b7241616aeb10b7
|
| 3 |
+
size 46952668
|
tokens.txt
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<blk> 0
|
| 2 |
+
<sos/eos> 1
|
| 3 |
+
<unk> 2
|
| 4 |
+
▁ 3
|
| 5 |
+
a 4
|
| 6 |
+
b 5
|
| 7 |
+
c 6
|
| 8 |
+
d 7
|
| 9 |
+
e 8
|
| 10 |
+
f 9
|
| 11 |
+
g 10
|
| 12 |
+
h 11
|
| 13 |
+
i 12
|
| 14 |
+
j 13
|
| 15 |
+
k 14
|
| 16 |
+
l 15
|
| 17 |
+
m 16
|
| 18 |
+
n 17
|
| 19 |
+
o 18
|
| 20 |
+
p 19
|
| 21 |
+
q 20
|
| 22 |
+
r 21
|
| 23 |
+
s 22
|
| 24 |
+
t 23
|
| 25 |
+
u 24
|
| 26 |
+
v 25
|
| 27 |
+
w 26
|
| 28 |
+
x 27
|
| 29 |
+
y 28
|
| 30 |
+
z 29
|
| 31 |
+
' 30
|
zipfa.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"script": "latin",
|
| 3 |
+
"frame_shift": 0.02,
|
| 4 |
+
"time_offset": 0.03,
|
| 5 |
+
"prior_scale": 0.0,
|
| 6 |
+
"log_priors": [
|
| 7 |
+
-3.433981418609619,
|
| 8 |
+
-3.433981418609619,
|
| 9 |
+
-3.433981418609619,
|
| 10 |
+
-3.433981418609619,
|
| 11 |
+
-3.433981418609619,
|
| 12 |
+
-3.433981418609619,
|
| 13 |
+
-3.433981418609619,
|
| 14 |
+
-3.433981418609619,
|
| 15 |
+
-3.433981418609619,
|
| 16 |
+
-3.433981418609619,
|
| 17 |
+
-3.433981418609619,
|
| 18 |
+
-3.433981418609619,
|
| 19 |
+
-3.433981418609619,
|
| 20 |
+
-3.433981418609619,
|
| 21 |
+
-3.433981418609619,
|
| 22 |
+
-3.433981418609619,
|
| 23 |
+
-3.433981418609619,
|
| 24 |
+
-3.433981418609619,
|
| 25 |
+
-3.433981418609619,
|
| 26 |
+
-3.433981418609619,
|
| 27 |
+
-3.433981418609619,
|
| 28 |
+
-3.433981418609619,
|
| 29 |
+
-3.433981418609619,
|
| 30 |
+
-3.433981418609619,
|
| 31 |
+
-3.433981418609619,
|
| 32 |
+
-3.433981418609619,
|
| 33 |
+
-3.433981418609619,
|
| 34 |
+
-3.433981418609619,
|
| 35 |
+
-3.433981418609619,
|
| 36 |
+
-3.433981418609619,
|
| 37 |
+
-3.433981418609619
|
| 38 |
+
]
|
| 39 |
+
}
|