Automatic Speech Recognition
MLX
English
Chinese
mega_asr_mlx
asr
speech-recognition
qwen3
apple-silicon
Instructions to use carloshuang1224/mega-asr-mlx with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use carloshuang1224/mega-asr-mlx with MLX:
# Download the model from the Hub pip install huggingface_hub[hf_xet] huggingface-cli download --local-dir mega-asr-mlx carloshuang1224/mega-asr-mlx
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Atomic Chat
Mega-ASR MLX
A high-accuracy automatic speech recognition model optimized for Apple Silicon (M1/M2/M3/M4) using MLX.
This model is an MLX port of Qwen3-ASR-1.7B with Mega-ASR LoRA adapters pre-merged, plus an Audio Quality Router for degraded audio detection.
Model Architecture
| Component | Details |
|---|---|
| Audio Encoder | 3-layer Conv2D stem + 24-layer Transformer (d_model=1024, 16 heads) |
| Decoder | Qwen3 1.7B β 28 layers, hidden=2048, 16 GQA heads (8 KV) |
| Aligner | conv_out (7680β1024) + proj1 (1024β1024) + proj2 (1024β2048) |
| Router | Mini Transformer (d_model=256, 4 layers, 4 heads) β binary audio quality classifier |
Total parameters: ~1.7B (decoder) + ~350M (encoder)
Quick Start
Install
pip install mega-asr-mlx
Download the model
huggingface-cli download carloshuang1224/mega-asr-mlx --local-dir ./mega-asr-mlx
Inference
CLI:
mega-asr --audio speech.wav --language English
Python API:
from mega_asr_mlx import MegaASRMLX
model = MegaASRMLX("./mega-asr-mlx")
text = model.transcribe("speech.wav", language="English")
print(text)
Advanced Usage
from mega_asr_mlx import MegaASRMLX
model = MegaASRMLX(
"./mega-asr-mlx",
use_lora=True, # always use LoRA (pre-merged)
router_threshold=0.5, # audio quality routing threshold
max_new_tokens=256, # max generated tokens
)
# Transcribe with routing info
result = model.transcribe("speech.wav", return_route_info=True)
# {"text": "...", "use_lora": True, "degraded_prob": 0.12}
# Transcribe numpy array
import soundfile as sf
audio, sr = sf.read("speech.wav")
text = model.transcribe(audio, sr=sr)
Performance
On Apple Silicon (M-series), with KV cache optimization:
- ~50 tokens/second generation speed
- Decoder weights: 3.8 GB (float16)
- Encoder weights: 606 MB (float16)
- Router weights: 2.3 MB (float16)
Files
mega-asr-mlx/
βββ decoder.safetensors # Qwen3 decoder weights (3.8 GB)
βββ encoder.safetensors # Audio encoder weights (606 MB)
βββ router.safetensors # Audio quality router (2.3 MB)
βββ config.json # Model configuration
βββ decoder_config.json # Decoder architecture config
βββ router_config.json # Router architecture config
βββ preprocessor_config.json # Audio preprocessing (Whisper-style mel)
βββ generation_config.json # Generation defaults
βββ tokenizer_config.json # Qwen2 tokenizer config
βββ vocab.json # Token vocabulary
βββ merges.txt # BPE merges
βββ chat_template.json # Qwen3-ASR chat template
Source Code
The full inference pipeline is bundled in the mega-asr-mlx pip package. After installing it, the source is available in the mega_asr_mlx/ directory.
Key files:
src/inference.pyβ End-to-end transcription scriptsrc/model.pyβMegaASRMLXclass with full pipelinesrc/audio_encoder.pyβ MLX audio encoder implementationsrc/router.pyβ Audio quality routersrc/convert.pyβ Weight conversion from PyTorch to MLX
How It Works
- Audio Input β 16kHz mono waveform
- Mel Extraction β 128-bin log-mel spectrogram (Whisper-style)
- Audio Encoder β Conv2D stem downsamples 8Γ, then 24 Transformer layers encode
- Decoder Input β Template:
<|im_start|>user\n<|audio_start|> [encoder_outputs] <|audio_end|><|im_end|>\n<|im_start|>assistant\n - Generation β Qwen3 decoder auto-regressively generates text with KV cache
Credits
- Base model: Qwen/Qwen3-ASR-1.7B by Alibaba Qwen Team
- LoRA adapter: Mega-ASR by VoiceInk
- MLX port: Converted and optimized for Apple Silicon
License
Apache 2.0
- Downloads last month
- 5
Hardware compatibility
Log In to add your hardware
Quantized