Instructions to use zeromodels/moonshine_base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- KerasFormers
How to use zeromodels/moonshine_base with KerasFormers:
# 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
- Keras
How to use zeromodels/moonshine_base with Keras:
# Available backend options are: "jax", "torch", "tensorflow". import os os.environ["KERAS_BACKEND"] = "jax" import keras model = keras.saving.load_model("hf://zeromodels/moonshine_base") - Notebooks
- Google Colab
- Kaggle
File size: 3,318 Bytes
fb72e93 3383de3 fb72e93 3383de3 fb72e93 3383de3 fb72e93 3383de3 fb72e93 de6a1b3 3383de3 fb72e93 3383de3 de6a1b3 3383de3 de6a1b3 3383de3 fb72e93 3383de3 de6a1b3 3383de3 | 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 | ---
pipeline_tag: automatic-speech-recognition
license: mit
base_model: UsefulSensors/moonshine-base
library_name: kerasformers
tags:
- keras
- kerasformers
- moonshine
- automatic-speech-recognition
- audio
- arxiv:2410.15608
- pytorch
- jax
- tf
---
## ***See [our collection](https://huggingface.co/collections/kerasformers/moonshine-6a6acc6dae5ff619b873d6c9) for all versions of Moonshine.***
# Run Moonshine with Keras 3: JAX, PyTorch, or TensorFlow
[](https://github.com/IMvision12/KerasFormers) [](https://imvision12.github.io/KerasFormers/moonshine/) [](https://huggingface.co/collections/kerasformers/moonshine-6a6acc6dae5ff619b873d6c9)
# kerasformers/moonshine_base
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)
Moonshine is an English ASR encoder-decoder built for **short / live** audio: the encoder sees the raw waveform length you pass in (no Whisper-style 30 s pad), so short commands stay cheap. Output is cased and punctuated.
For more details on the model, please go to the upstream [model card](https://huggingface.co/UsefulSensors/moonshine-base).
Pure-**Keras 3** conversion of [`UsefulSensors/moonshine-base`](https://huggingface.co/UsefulSensors/moonshine-base) for [kerasformers](https://github.com/IMvision12/KerasFormers). One implementation runs unmodified on **TensorFlow / Torch / JAX**.
This is an **ASR** checkpoint (`MoonshineConditionalGenerate`).
## ✨ Quick start
```python
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
import soundfile as sf
from kerasformers.models.moonshine import (
MoonshineProcessor,
MoonshineConditionalGenerate,
)
model = MoonshineConditionalGenerate.from_weights("kerasformers/moonshine_base")
processor = MoonshineProcessor.from_weights("kerasformers/moonshine_base")
audio, sr = sf.read("your_audio.wav", dtype="float32") # 16 kHz mono
# Cost scales with clip length: no fixed 30 s pad like Whisper.
text = model.generate(audio, processor)
print(repr(text[0]))
```
Load any Moonshine variant the same way with `from_weights("kerasformers/<variant>")`:
| Variant | Hub |
|---|---|
| `moonshine_tiny` | [`kerasformers/moonshine_tiny`](https://huggingface.co/kerasformers/moonshine_tiny) |
| `moonshine_base` | [`kerasformers/moonshine_base`](https://huggingface.co/kerasformers/moonshine_base) |
## Tips
- Set `KERAS_BACKEND` **before** importing Keras / kerasformers.
- Prefer `MoonshineProcessor.from_weights(...)` so feature extraction matches.
- English-only; pass a list of waveforms to batch.
- See [Moonshine docs](https://imvision12.github.io/KerasFormers/moonshine/) and [Loading Weights](https://imvision12.github.io/KerasFormers/loading_weights/).
- Community / upstream safetensors still work via the `hf:` prefix, e.g. `MoonshineConditionalGenerate.from_weights("hf:UsefulSensors/moonshine-base")`.
## Special Thanks
A huge thank you to the Useful Sensors Moonshine authors for creating and releasing these models.
License: MIT.
|