Add zipfa model
Browse files- README.md +70 -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,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- de
|
| 5 |
+
datasets:
|
| 6 |
+
- facebook/multilingual_librispeech
|
| 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 German: small CTC forced aligner
|
| 17 |
+
|
| 18 |
+
Forced aligner for German. Given audio and its transcript, it returns a start and end time for every word.
|
| 19 |
+
|
| 20 |
+
Text uses the Latin alphabet of the English model: umlauts are folded (schön → schon) and ß becomes ss, but times are reported for the words as written.
|
| 21 |
+
|
| 22 |
+
## Training
|
| 23 |
+
|
| 24 |
+
Multilingual LibriSpeech German (CC BY 4.0), 1,967 h, 20 epochs, starting from the English zipfa model; export averaged over the last 7. MLS has no reference word timings, so the time offset (0.03 s) is the English model's.
|
| 25 |
+
|
| 26 |
+
## Accuracy
|
| 27 |
+
|
| 28 |
+
On 200 pairs (400 clips) from the MLS German test split:
|
| 29 |
+
|
| 30 |
+
| | junction pass rate | mean junction error | greedy character error rate |
|
| 31 |
+
|---|---|---|---|
|
| 32 |
+
| **this model** | **0.955** | 21.0 ms | **0.046** |
|
| 33 |
+
| this model, int8 | 0.955 | 20.9 ms | 0.046 |
|
| 34 |
+
| the English zipfa model on the same audio | 0.920 | 34.5 ms | 0.504 |
|
| 35 |
+
|
| 36 |
+
Junction test: two clips joined by 0.3 s of silence; it passes when the first clip's words end before the join and the second's start after the silence, within 0.10 s. Of the 9 failed pairs, about 7 have a transcript word at the join that is not in the audio (for example a clip whose transcript opens with "teil zwei kapitel dreiundzwanzig", which its audio does not contain); 2 are alignment errors on clean clips. Word boundary error is not measured: no German reference timings exist.
|
| 37 |
+
|
| 38 |
+
## Files
|
| 39 |
+
|
| 40 |
+
| file | what it is |
|
| 41 |
+
|---|---|
|
| 42 |
+
| `model.onnx` | full-precision model (47 MB) |
|
| 43 |
+
| `model.int8.onnx` | int8-quantised model (19 MB), same accuracy, faster on CPU |
|
| 44 |
+
| `tokens.txt`, `bpe.model` | the character tokenizer |
|
| 45 |
+
| `zipfa.json` | script, frame shift (20 ms) and calibrated time offset |
|
| 46 |
+
|
| 47 |
+
## Use
|
| 48 |
+
|
| 49 |
+
With the `zipfa` package (numpy + onnxruntime + kaldi-native-fbank):
|
| 50 |
+
|
| 51 |
+
```python
|
| 52 |
+
from huggingface_hub import snapshot_download
|
| 53 |
+
from zipfa.audio import load_audio
|
| 54 |
+
from zipfa.model import ZipfaModel
|
| 55 |
+
|
| 56 |
+
model = ZipfaModel(snapshot_download("aloudreader/zipfa-german"), int8=True)
|
| 57 |
+
for w in model.align(load_audio("clip.wav"), "guten morgen zusammen"):
|
| 58 |
+
print(w.word, w.start, w.end)
|
| 59 |
+
```
|
| 60 |
+
|
| 61 |
+
or `python -m zipfa.cli --model-dir <folder> --audio clip.wav --text "..." --int8`.
|
| 62 |
+
|
| 63 |
+
- 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.
|
| 64 |
+
- Output: one start and end time per word of the given text, 20 ms resolution.
|
| 65 |
+
- 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`).
|
| 66 |
+
- 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.
|
| 67 |
+
|
| 68 |
+
## Model
|
| 69 |
+
|
| 70 |
+
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:5629bd56466b7f1809e2787d22f06f14e9be6f30708712c3dda0bd660e5c620c
|
| 3 |
+
size 19364248
|
model.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bde2a913d116d302372b40084297380edd3817a663eee2e48448bdbce996aafd
|
| 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.4339935779571533,
|
| 8 |
+
-3.4339935779571533,
|
| 9 |
+
-3.4339935779571533,
|
| 10 |
+
-3.4339935779571533,
|
| 11 |
+
-3.4339935779571533,
|
| 12 |
+
-3.4339935779571533,
|
| 13 |
+
-3.4339935779571533,
|
| 14 |
+
-3.4339935779571533,
|
| 15 |
+
-3.4339935779571533,
|
| 16 |
+
-3.4339935779571533,
|
| 17 |
+
-3.4339935779571533,
|
| 18 |
+
-3.4339935779571533,
|
| 19 |
+
-3.4339935779571533,
|
| 20 |
+
-3.4339935779571533,
|
| 21 |
+
-3.4339935779571533,
|
| 22 |
+
-3.4339935779571533,
|
| 23 |
+
-3.4339935779571533,
|
| 24 |
+
-3.4339935779571533,
|
| 25 |
+
-3.4339935779571533,
|
| 26 |
+
-3.4339935779571533,
|
| 27 |
+
-3.4339935779571533,
|
| 28 |
+
-3.4339935779571533,
|
| 29 |
+
-3.4339935779571533,
|
| 30 |
+
-3.4339935779571533,
|
| 31 |
+
-3.4339935779571533,
|
| 32 |
+
-3.4339935779571533,
|
| 33 |
+
-3.4339935779571533,
|
| 34 |
+
-3.4339935779571533,
|
| 35 |
+
-3.4339935779571533,
|
| 36 |
+
-3.4339935779571533,
|
| 37 |
+
-3.4339935779571533
|
| 38 |
+
]
|
| 39 |
+
}
|