Instructions to use zeromodels/moonshine_tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ZeroModels
How to use zeromodels/moonshine_tiny with ZeroModels:
# pip install -U zeromodels # ZeroModels is pure Keras 3, so pick a backend: "jax", "torch" or "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" from zeromodels import AutoZModel # AutoZModel reads the repo's model_type and loads the matching class. # For a task head use the matching loader, e.g. AutoZMImageClassify / AutoZMDetect / # AutoZMSemanticSegment / AutoZMTextGenerate (see zeromodels.auto). model = AutoZModel.from_weights("zeromodels/moonshine_tiny") - Keras
How to use zeromodels/moonshine_tiny with Keras:
# !pip install -U keras tensorflow huggingface_hub # Keras needs TensorFlow installed to read "hf://" paths, so the tensorflow backend is selected here; # "jax" and "torch" also work for computation once TensorFlow is installed. import os os.environ["KERAS_BACKEND"] = "tensorflow" import keras model = keras.saving.load_model("hf://zeromodels/moonshine_tiny") - Notebooks
- Google Colab
- Kaggle
Migrate to zeromodels (rename kf_*.json -> zm_*.json, fix refs in config + README, ensure tag + badge)
Browse files- README.md +14 -14
- kf_config.json → zm_config.json +37 -37
- kf_preprocessor.json → zm_preprocessor.json +8 -8
README.md
CHANGED
|
@@ -2,10 +2,10 @@
|
|
| 2 |
pipeline_tag: automatic-speech-recognition
|
| 3 |
license: mit
|
| 4 |
base_model: UsefulSensors/moonshine-tiny
|
| 5 |
-
library_name:
|
| 6 |
tags:
|
| 7 |
- keras
|
| 8 |
-
-
|
| 9 |
- moonshine
|
| 10 |
- automatic-speech-recognition
|
| 11 |
- audio
|
|
@@ -15,13 +15,13 @@ tags:
|
|
| 15 |
- tf
|
| 16 |
---
|
| 17 |
|
| 18 |
-
## ***See [our collection](https://huggingface.co/collections/
|
| 19 |
|
| 20 |
# Run Moonshine with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
|
| 22 |
-
[](https://arxiv.org/abs/2410.15608) · [HF Papers](https://huggingface.co/papers/2410.15608)
|
| 27 |
|
|
@@ -29,7 +29,7 @@ Moonshine is an English ASR encoder-decoder built for **short / live** audio: th
|
|
| 29 |
|
| 30 |
For more details on the model, please go to the upstream [model card](https://huggingface.co/UsefulSensors/moonshine-tiny).
|
| 31 |
|
| 32 |
-
Pure-**Keras 3** conversion of [`UsefulSensors/moonshine-tiny`](https://huggingface.co/UsefulSensors/moonshine-tiny) for [
|
| 33 |
|
| 34 |
This is an **ASR** checkpoint (`MoonshineConditionalGenerate`).
|
| 35 |
|
|
@@ -40,13 +40,13 @@ import os
|
|
| 40 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 41 |
|
| 42 |
import soundfile as sf
|
| 43 |
-
from
|
| 44 |
MoonshineProcessor,
|
| 45 |
MoonshineConditionalGenerate,
|
| 46 |
)
|
| 47 |
|
| 48 |
-
model = MoonshineConditionalGenerate.from_weights("
|
| 49 |
-
processor = MoonshineProcessor.from_weights("
|
| 50 |
|
| 51 |
audio, sr = sf.read("your_audio.wav", dtype="float32") # 16 kHz mono
|
| 52 |
# Cost scales with clip length: no fixed 30 s pad like Whisper.
|
|
@@ -54,19 +54,19 @@ text = model.generate(audio, processor)
|
|
| 54 |
print(repr(text[0]))
|
| 55 |
```
|
| 56 |
|
| 57 |
-
Load any Moonshine variant the same way with `from_weights("
|
| 58 |
|
| 59 |
| Variant | Hub |
|
| 60 |
|---|---|
|
| 61 |
-
| `moonshine_tiny` | [`
|
| 62 |
-
| `moonshine_base` | [`
|
| 63 |
|
| 64 |
## Tips
|
| 65 |
|
| 66 |
-
- Set `KERAS_BACKEND` **before** importing Keras /
|
| 67 |
- Prefer `MoonshineProcessor.from_weights(...)` so feature extraction matches.
|
| 68 |
- English-only; pass a list of waveforms to batch.
|
| 69 |
-
- See [Moonshine docs](https://imvision12.github.io/
|
| 70 |
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `MoonshineConditionalGenerate.from_weights("hf:UsefulSensors/moonshine-tiny")`.
|
| 71 |
|
| 72 |
## Special Thanks
|
|
|
|
| 2 |
pipeline_tag: automatic-speech-recognition
|
| 3 |
license: mit
|
| 4 |
base_model: UsefulSensors/moonshine-tiny
|
| 5 |
+
library_name: zeromodels
|
| 6 |
tags:
|
| 7 |
- keras
|
| 8 |
+
- zeromodels
|
| 9 |
- moonshine
|
| 10 |
- automatic-speech-recognition
|
| 11 |
- audio
|
|
|
|
| 15 |
- tf
|
| 16 |
---
|
| 17 |
|
| 18 |
+
## ***See [our collection](https://huggingface.co/collections/zeromodels/moonshine-6a6acc6dae5ff619b873d6c9) for all versions of Moonshine.***
|
| 19 |
|
| 20 |
# Run Moonshine with Keras 3: JAX, PyTorch, or TensorFlow
|
| 21 |
|
| 22 |
+
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/moonshine/) [](https://huggingface.co/collections/zeromodels/moonshine-6a6acc6dae5ff619b873d6c9)
|
| 23 |
|
| 24 |
+
# zeromodels/moonshine_tiny
|
| 25 |
|
| 26 |
Paper: [Moonshine: Speech Recognition for Live Transcription and Voice Commands (arXiv:2410.15608)](https://arxiv.org/abs/2410.15608) · [HF Papers](https://huggingface.co/papers/2410.15608)
|
| 27 |
|
|
|
|
| 29 |
|
| 30 |
For more details on the model, please go to the upstream [model card](https://huggingface.co/UsefulSensors/moonshine-tiny).
|
| 31 |
|
| 32 |
+
Pure-**Keras 3** conversion of [`UsefulSensors/moonshine-tiny`](https://huggingface.co/UsefulSensors/moonshine-tiny) for [zeromodels](https://github.com/IMvision12/ZeroModels). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
|
| 33 |
|
| 34 |
This is an **ASR** checkpoint (`MoonshineConditionalGenerate`).
|
| 35 |
|
|
|
|
| 40 |
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
|
| 41 |
|
| 42 |
import soundfile as sf
|
| 43 |
+
from zeromodels.models.moonshine import (
|
| 44 |
MoonshineProcessor,
|
| 45 |
MoonshineConditionalGenerate,
|
| 46 |
)
|
| 47 |
|
| 48 |
+
model = MoonshineConditionalGenerate.from_weights("zeromodels/moonshine_tiny")
|
| 49 |
+
processor = MoonshineProcessor.from_weights("zeromodels/moonshine_tiny")
|
| 50 |
|
| 51 |
audio, sr = sf.read("your_audio.wav", dtype="float32") # 16 kHz mono
|
| 52 |
# Cost scales with clip length: no fixed 30 s pad like Whisper.
|
|
|
|
| 54 |
print(repr(text[0]))
|
| 55 |
```
|
| 56 |
|
| 57 |
+
Load any Moonshine variant the same way with `from_weights("zeromodels/<variant>")`:
|
| 58 |
|
| 59 |
| Variant | Hub |
|
| 60 |
|---|---|
|
| 61 |
+
| `moonshine_tiny` | [`zeromodels/moonshine_tiny`](https://huggingface.co/zeromodels/moonshine_tiny) |
|
| 62 |
+
| `moonshine_base` | [`zeromodels/moonshine_base`](https://huggingface.co/zeromodels/moonshine_base) |
|
| 63 |
|
| 64 |
## Tips
|
| 65 |
|
| 66 |
+
- Set `KERAS_BACKEND` **before** importing Keras / zeromodels.
|
| 67 |
- Prefer `MoonshineProcessor.from_weights(...)` so feature extraction matches.
|
| 68 |
- English-only; pass a list of waveforms to batch.
|
| 69 |
+
- See [Moonshine docs](https://imvision12.github.io/ZeroModels/moonshine/) and [Loading Weights](https://imvision12.github.io/ZeroModels/loading_weights/).
|
| 70 |
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `MoonshineConditionalGenerate.from_weights("hf:UsefulSensors/moonshine-tiny")`.
|
| 71 |
|
| 72 |
## Special Thanks
|
kf_config.json → zm_config.json
RENAMED
|
@@ -1,38 +1,38 @@
|
|
| 1 |
-
{
|
| 2 |
-
"library_name": "
|
| 3 |
-
"
|
| 4 |
-
"model_module": "
|
| 5 |
-
"model_class": "MoonshineModel",
|
| 6 |
-
"variant": "moonshine_tiny",
|
| 7 |
-
"weights": "model.weights.h5",
|
| 8 |
-
"schema_version": 2,
|
| 9 |
-
"weight_dtype": "float32",
|
| 10 |
-
"model_type": "moonshine",
|
| 11 |
-
"audio_config": {
|
| 12 |
-
"num_layers": 6,
|
| 13 |
-
"attention_heads": 8,
|
| 14 |
-
"num_kv_heads": null,
|
| 15 |
-
"ffn_dim": 1152,
|
| 16 |
-
"activation": "gelu"
|
| 17 |
-
},
|
| 18 |
-
"text_config": {
|
| 19 |
-
"num_layers": 6,
|
| 20 |
-
"attention_heads": 8,
|
| 21 |
-
"num_kv_heads": null,
|
| 22 |
-
"ffn_dim": 1152,
|
| 23 |
-
"activation": "silu",
|
| 24 |
-
"vocab_size": 32768,
|
| 25 |
-
"max_position_embeddings": 194,
|
| 26 |
-
"partial_rotary_factor": 0.9,
|
| 27 |
-
"rope_theta": 10000.0
|
| 28 |
-
},
|
| 29 |
-
"hidden_dim": 288,
|
| 30 |
-
"layer_norm_eps": 1e-05,
|
| 31 |
-
"generate_args": {
|
| 32 |
-
"bos_token_id": 1,
|
| 33 |
-
"pad_token_id": 2,
|
| 34 |
-
"decoder_start_token_id": 1,
|
| 35 |
-
"eos_token_id": 2,
|
| 36 |
-
"max_length": 194
|
| 37 |
-
}
|
| 38 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.2.1",
|
| 4 |
+
"model_module": "zeromodels.models.moonshine",
|
| 5 |
+
"model_class": "MoonshineModel",
|
| 6 |
+
"variant": "moonshine_tiny",
|
| 7 |
+
"weights": "model.weights.h5",
|
| 8 |
+
"schema_version": 2,
|
| 9 |
+
"weight_dtype": "float32",
|
| 10 |
+
"model_type": "moonshine",
|
| 11 |
+
"audio_config": {
|
| 12 |
+
"num_layers": 6,
|
| 13 |
+
"attention_heads": 8,
|
| 14 |
+
"num_kv_heads": null,
|
| 15 |
+
"ffn_dim": 1152,
|
| 16 |
+
"activation": "gelu"
|
| 17 |
+
},
|
| 18 |
+
"text_config": {
|
| 19 |
+
"num_layers": 6,
|
| 20 |
+
"attention_heads": 8,
|
| 21 |
+
"num_kv_heads": null,
|
| 22 |
+
"ffn_dim": 1152,
|
| 23 |
+
"activation": "silu",
|
| 24 |
+
"vocab_size": 32768,
|
| 25 |
+
"max_position_embeddings": 194,
|
| 26 |
+
"partial_rotary_factor": 0.9,
|
| 27 |
+
"rope_theta": 10000.0
|
| 28 |
+
},
|
| 29 |
+
"hidden_dim": 288,
|
| 30 |
+
"layer_norm_eps": 1e-05,
|
| 31 |
+
"generate_args": {
|
| 32 |
+
"bos_token_id": 1,
|
| 33 |
+
"pad_token_id": 2,
|
| 34 |
+
"decoder_start_token_id": 1,
|
| 35 |
+
"eos_token_id": 2,
|
| 36 |
+
"max_length": 194
|
| 37 |
+
}
|
| 38 |
}
|
kf_preprocessor.json → zm_preprocessor.json
RENAMED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
{
|
| 2 |
-
"library_name": "
|
| 3 |
-
"
|
| 4 |
-
"preprocessor_module": "
|
| 5 |
-
"preprocessor_class": "MoonshineFeatureExtractor",
|
| 6 |
-
"variant": "moonshine_tiny",
|
| 7 |
-
"sampling_rate": 16000,
|
| 8 |
-
"padding_value": 0.0
|
| 9 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"library_name": "zeromodels",
|
| 3 |
+
"zeromodels_version": "1.1.3",
|
| 4 |
+
"preprocessor_module": "zeromodels.models.moonshine",
|
| 5 |
+
"preprocessor_class": "MoonshineFeatureExtractor",
|
| 6 |
+
"variant": "moonshine_tiny",
|
| 7 |
+
"sampling_rate": 16000,
|
| 8 |
+
"padding_value": 0.0
|
| 9 |
}
|