File size: 4,002 Bytes
b43c5f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc7190e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b43c5f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
language:
- fa
- en
license: gpl-3.0
library_name: coreml
pipeline_tag: automatic-speech-recognition
base_model:
- Reza2kn/Shenava-Rizeh-v1.5
base_model_relation: quantized
tags:
- automatic-speech-recognition
- persian
- farsi
- zipformer
- rnnt
- transducer
- streaming
- on-device
- shenava
- coreml
- fp16
- ios
---

# 🎙️ Shenava-Rizeh-v1.5-CoreML-iOS15-fp16 (streaming)

A cache-aware **streaming** Core ML export of [Shenava Rizeh v1.5](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.5) for live captions on iOS 15+ / macOS 12+. It uses the NeuralNetwork format with fp16 weights. Each encoder call consumes **320 ms** of audio and returns 8 encoder frames. Attention looks back up to 128 frames (2.56 s), and all caches are explicit inputs and outputs.

> **Not a drop-in for the v1.0 file.** v1.0 was CTC with 170 ms steps. v1.5 is an RNN-T transducer: the encoder step is followed by a decoder/joiner loop (see `run_coreml_stream.py`).

## Accuracy (EVEN half of golden-6669 + FLEURS, 2,758 clips, no LM, official TT, beam 4)

| Mode | TT |
|---|---|
| Offline (whole utterance) | 4.35 |
| **Streaming, 320 ms chunks (this export)** | **5.31** |
| Streaming, 640 ms chunks (re-export with `export_coreml_stream.py model.tzf out 32 128`) | 5.19 |
| Streaming, 320 ms chunks, int8 ONNX | 5.32 |

These streaming numbers come from the identical ONNX graph in sherpa-onnx. The traced PyTorch graph that was converted here reproduces the onnxruntime tokens exactly (`reference/`). **The Core ML fp16 runtime itself has not been run on Apple hardware yet.** Run `python run_coreml_stream.py` once on a Mac; it should print `token match: True`.

## Files

| Encoder step | Format / target | Size | Error vs onnxruntime fp32 (8 clips, every chunk) | Tokens identical | M2 ms per 320 ms step (CPU / GPU / ALL) |
|---|---|---|---|---|---|
| `shenava_rizeh_v1_5_encoder_streaming_c16_l128_ios15_fp16.mlmodel` | NeuralNetwork, iOS 15+ | 109 MB | 0.08 % | 8/8 | 15.6 / 16.4 / 16.5 |
| `shenava_rizeh_v1_5_encoder_streaming_c16_l128_ios15_int8.mlmodel` | NeuralNetwork, iOS 15+, int8 weights | 56 MB | 1.5 % | 8/8 | 16.0 / 16.7 / 16.7 |
| `ios18/shenava_rizeh_v1_5_encoder_streaming_c16_l128_ios18_int4.mlpackage` | ML Program, iOS 18+, int4 weights (blocks of 32) | 34 MB | see note | n/a | **7.4** / 18.8 / 18.5 |

**int4 note:** on the M2 this package reproduces a PyTorch model with the same int4 weights to within 0.1 %. That model's streaming score on the held-out half is **TT 5.37**, vs 5.31 for fp32 (official TT, no LM). The NeuralNetwork format has no block-wise int4, so int4 needs iOS 18.

**Other files:**

- `..._manifest.json`: input shapes. All 92 caches start at zero; `processed_lens` is int32.
- The decoder and joiner (`*_ios15_fp16.mlmodel`) are shared by every encoder.
- Decoder: `y` int32 (1, 2) → `decoder_out` (1, 512).
- Joiner: (`encoder_out` (1, 512), `decoder_out` (1, 512)) → `logit` (1, 2080).
- Encoder step I/O: `x` (1, 45, 80) + caches → `encoder_out` (1, 8, 512) + `new_<cache>`.
- `tokens.txt`, `run_coreml_stream.py [encoder file]`, `reference/`, `export_coreml_stream.py` (`MLPROGRAM=1 FQ=1` gives the iOS 18 int4 base), `cmq2.py`.

## Streaming loop

1. Compute 80-dim kaldi fbank on the incoming audio (same settings as the [fp16 package](https://huggingface.co/Reza2kn/Shenava-Rizeh-v1.5-CoreML-fp16#features-must-match-exactly)).
2. Each step, take **45 frames** and advance by **32** (a 13-frame overlap is needed by the subsampling).
3. Call the encoder with `x` and all caches, then replace each cache with its `new_` output.
4. For each of the 8 output frames, run greedy RNN-T:
   - Blank is 0 and the decoder context is the last 2 tokens, starting `[0, 0]`.
   - **Mask ids 32–1055** (the English block).
5. At end of speech, append about 0.8 s of silence so the final words come out.

Numbers come out as Persian digits, and punctuation is included (teacher-style text), so no ITN is needed.

## License

GPL-3.0, inherited from tinyasr.