Skip to content

add moonshine stt model#552

Merged
lucasnewman merged 3 commits intoBlaizzy:mainfrom
mm65x:add-moonshine-stt
Mar 9, 2026
Merged

add moonshine stt model#552
lucasnewman merged 3 commits intoBlaizzy:mainfrom
mm65x:add-moonshine-stt

Conversation

@mm65x
Copy link
Copy Markdown
Contributor

@mm65x mm65x commented Mar 8, 2026

Context

Moonshine is a lightweight ASR model from Useful Sensors (https://github.com/usefulsensors/moonshine), comparable accuracy to Whisper but much smaller (27M tiny, 61M base). It processes raw audio through a learned conv frontend rather than mel spectrograms, so it runs efficiently on Apple Silicon.

Description

This adds Moonshine to the STT pipeline. The implementation is based on the HuggingFace transformers reference and loads safetensors weights from the hub.

The encoder has a 3 layer conv frontend feeding into transformer layers with RoPE. The decoder uses cross attention and SwiGLU. Both tiny and base variants are supported through config.

Changes in the codebase

  • mlx_audio/stt/models/moonshine/moonshine.py: model with encoder (conv frontend + transformer), decoder (cross attention + SwiGLU), RoPE, generate(), sanitize()
  • mlx_audio/stt/models/moonshine/config.py: config matching HF defaults
  • mlx_audio/stt/models/moonshine/tests/test_moonshine.py: 25 unit tests
  • mlx_audio/stt/utils.py: register "moonshine" in MODEL_REMAPPING

Changes outside the codebase

None.

Additional information

  • Components were numerically verified against the HF PyTorch implementation
  • Tokenizer loaded via AutoTokenizer in post_load_hook

Checklist

  • Tests added/updated
  • Documentation updated
  • Issue referenced - STT roadmap

return model

@classmethod
def from_pretrained(cls, path_or_repo: str, *, dtype: mx.Dtype = mx.float32):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a deprecation warning here since it's new -- either leave it out or remove the warning if you want to keep it.

Copy link
Copy Markdown
Collaborator

@lucasnewman lucasnewman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mm65x This is really well done, thanks! Can you please run the formatter: pre-commit run --all to clear tests and see the comment? Then we can merge.

@mm65x
Copy link
Copy Markdown
Contributor Author

mm65x commented Mar 8, 2026

done, ran the formatter

@lucasnewman
Copy link
Copy Markdown
Collaborator

@mm65x Looks like a merge conflict from your other PR, if you can fix it up I'll merge.

@mm65x mm65x force-pushed the add-moonshine-stt branch from 4df6101 to b7fbade Compare March 8, 2026 20:26
@mm65x
Copy link
Copy Markdown
Contributor Author

mm65x commented Mar 8, 2026

rebased on main, conflict resolved

@lucasnewman lucasnewman merged commit 3b659b1 into Blaizzy:main Mar 9, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants