Instructions to use litert-community/moonshine-tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/moonshine-tiny with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Commit ·
beb49ee
1
Parent(s): 3008d1a
Fix i8 variant: keep encoder float32 (quantized encoder was broken) (#2)
Browse files- Fix i8 variant: keep encoder float32 (quantized encoder was broken) (435b7e671b41230124c010ee318e10b70a4c9457)
Co-authored-by: Majima <mlboydaisuke@users.noreply.huggingface.co>
- README.md +28 -17
- moonshine_tiny_5s_i8.tflite +2 -2
README.md
CHANGED
|
@@ -20,9 +20,9 @@ tags:
|
|
| 20 |
It transcribes English speech and is designed for fast on-device inference.
|
| 21 |
|
| 22 |
This repository packages the model for [LiteRT](https://ai.google.dev/edge/litert):
|
| 23 |
-
a float32 model,
|
| 24 |
-
|
| 25 |
-
device NPU.
|
| 26 |
|
| 27 |
## Model description
|
| 28 |
|
|
@@ -49,7 +49,7 @@ transcription loop:
|
|
| 49 |
| File | Description |
|
| 50 |
|---|---|
|
| 51 |
| `moonshine_tiny_5s_f32.tflite` | float32 model (109 MB) |
|
| 52 |
-
| `moonshine_tiny_5s_i8.tflite` |
|
| 53 |
| `moonshine_tiny_5s_f32_MediaTek_*.tflite` | float32 AOT-compiled for MediaTek NPUs (per SoC) |
|
| 54 |
| `moonshine_tiny_5s_f32_Qualcomm_*.tflite` | float32 AOT-compiled for Qualcomm NPUs (per SoC) |
|
| 55 |
|
|
@@ -175,6 +175,12 @@ if __name__ == "__main__":
|
|
| 175 |
python transcribe.py --wav sample.wav
|
| 176 |
```
|
| 177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
## Performance
|
| 179 |
|
| 180 |
Measured on one 5 s window of continuous speech (11 output tokens), CPU
|
|
@@ -186,30 +192,35 @@ with the CPU accelerator at default threading:
|
|
| 186 |
| Device | Variant | Encode | Decode | Window total | RTF |
|
| 187 |
|---|---|---|---|---|---|
|
| 188 |
| iPhone 17 Pro | f32 | 10.9 ms | 70.2 ms | 81.2 ms | 0.016 |
|
| 189 |
-
| iPhone 17 Pro | i8 |
|
| 190 |
| Apple M4 Max (macOS) | f32 | 8.1 ms | 79.4 ms | 87.5 ms | 0.017 |
|
| 191 |
-
| Apple M4 Max (macOS) | i8 |
|
| 192 |
| Raspberry Pi 5 | f32 | 50.7 ms | 444.7 ms | 495.3 ms | 0.099 |
|
| 193 |
-
| Raspberry Pi 5 | i8 |
|
| 194 |
|
| 195 |
RTF = processing time / audio duration (lower is better; below 1.0 is faster
|
| 196 |
than real time). Decode dominates and scales with the number of emitted
|
| 197 |
tokens, so dense speech takes proportionally longer than sparse speech. The
|
| 198 |
-
i8 model
|
| 199 |
-
silicon (M4 Max, iPhone 17 Pro) the two are equally
|
| 200 |
-
decode is deterministic across platforms: the same window
|
| 201 |
-
bit-identical token sequences on all three devices
|
|
|
|
|
|
|
|
|
|
| 202 |
|
| 203 |
### Accuracy note
|
| 204 |
|
| 205 |
In a 12-clip spot check (LibriSpeech dev-clean samples plus two
|
| 206 |
public-domain clips), the f32 model transcribes clips of up to 5 s at
|
| 207 |
-
near-reference quality
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
the
|
| 212 |
-
|
|
|
|
|
|
|
| 213 |
|
| 214 |
For the source model's quality, the
|
| 215 |
[Moonshine paper](https://arxiv.org/abs/2410.15608) reports that Moonshine
|
|
|
|
| 20 |
It transcribes English speech and is designed for fast on-device inference.
|
| 21 |
|
| 22 |
This repository packages the model for [LiteRT](https://ai.google.dev/edge/litert):
|
| 23 |
+
a float32 model, an int8 model (dynamic-range-quantized decoder with a
|
| 24 |
+
float32 encoder), and ahead-of-time compiled variants for a range of MediaTek
|
| 25 |
+
and Qualcomm SoCs so the model can run on the device NPU.
|
| 26 |
|
| 27 |
## Model description
|
| 28 |
|
|
|
|
| 49 |
| File | Description |
|
| 50 |
|---|---|
|
| 51 |
| `moonshine_tiny_5s_f32.tflite` | float32 model (109 MB) |
|
| 52 |
+
| `moonshine_tiny_5s_i8.tflite` | int8 model (52 MB): float32 encoder + dynamic-range int8 decoder |
|
| 53 |
| `moonshine_tiny_5s_f32_MediaTek_*.tflite` | float32 AOT-compiled for MediaTek NPUs (per SoC) |
|
| 54 |
| `moonshine_tiny_5s_f32_Qualcomm_*.tflite` | float32 AOT-compiled for Qualcomm NPUs (per SoC) |
|
| 55 |
|
|
|
|
| 175 |
python transcribe.py --wav sample.wav
|
| 176 |
```
|
| 177 |
|
| 178 |
+
### Android sample app
|
| 179 |
+
|
| 180 |
+
For an on-device Android demo that runs Moonshine (and other ASR models) with
|
| 181 |
+
hardware acceleration, see the LiteRT
|
| 182 |
+
[speech recognition sample](https://github.com/google-ai-edge/litert-samples/tree/main/samples/litert/speech_recognition).
|
| 183 |
+
|
| 184 |
## Performance
|
| 185 |
|
| 186 |
Measured on one 5 s window of continuous speech (11 output tokens), CPU
|
|
|
|
| 192 |
| Device | Variant | Encode | Decode | Window total | RTF |
|
| 193 |
|---|---|---|---|---|---|
|
| 194 |
| iPhone 17 Pro | f32 | 10.9 ms | 70.2 ms | 81.2 ms | 0.016 |
|
| 195 |
+
| iPhone 17 Pro | i8 | 10.7 ms | 69.3 ms | 80.0 ms | 0.016 |
|
| 196 |
| Apple M4 Max (macOS) | f32 | 8.1 ms | 79.4 ms | 87.5 ms | 0.017 |
|
| 197 |
+
| Apple M4 Max (macOS) | i8 | 7.4 ms | 72.6 ms | 80.0 ms | 0.016 |
|
| 198 |
| Raspberry Pi 5 | f32 | 50.7 ms | 444.7 ms | 495.3 ms | 0.099 |
|
| 199 |
+
| Raspberry Pi 5 | i8 | 50.3 ms | 267.4 ms | 317.7 ms | 0.064 |
|
| 200 |
|
| 201 |
RTF = processing time / audio duration (lower is better; below 1.0 is faster
|
| 202 |
than real time). Decode dominates and scales with the number of emitted
|
| 203 |
tokens, so dense speech takes proportionally longer than sparse speech. The
|
| 204 |
+
i8 model's int8 decoder makes it about 1.6x faster than f32 on the Pi 5's
|
| 205 |
+
Cortex-A76; on Apple silicon (M4 Max, iPhone 17 Pro) the two are equally
|
| 206 |
+
fast. The greedy decode is deterministic across platforms: the same window
|
| 207 |
+
produces bit-identical f32 token sequences on all three devices, the i8
|
| 208 |
+
model reproduces the f32 token sequence exactly on the dense test window on
|
| 209 |
+
both Apple devices, and its transcripts are identical between the M4 Max
|
| 210 |
+
and the Pi 5 on all 12 test clips.
|
| 211 |
|
| 212 |
### Accuracy note
|
| 213 |
|
| 214 |
In a 12-clip spot check (LibriSpeech dev-clean samples plus two
|
| 215 |
public-domain clips), the f32 model transcribes clips of up to 5 s at
|
| 216 |
+
near-reference quality, and the i8 model matches it: the same overall word
|
| 217 |
+
error rate on the 12-clip harness (within chunking noise), word-level
|
| 218 |
+
divergence from the f32 transcripts of 2.5%, and encoder output that is
|
| 219 |
+
bit-identical to f32 because the encoder is not quantized. The encoder is kept in float32
|
| 220 |
+
deliberately — the convolutional audio frontend on the raw waveform does not
|
| 221 |
+
survive dynamic-range quantization (an earlier fully-quantized i8 upload
|
| 222 |
+
degraded badly for exactly this reason) — while the decoder, which dominates
|
| 223 |
+
latency, carries the int8 weights.
|
| 224 |
|
| 225 |
For the source model's quality, the
|
| 226 |
[Moonshine paper](https://arxiv.org/abs/2410.15608) reports that Moonshine
|
moonshine_tiny_5s_i8.tflite
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:97abdeea122d579229091659c24c59d988c6419d453a200f6471241a53b9a9b9
|
| 3 |
+
size 51936896
|