--- license: cc-by-nc-4.0 language: - en tags: - mlx - audio - music - audio-super-resolution - audiosr - latent-diffusion - quantized - int4 base_model: haoheliu/audiosr_basic library_name: mlx pipeline_tag: audio-to-audio --- # AudioSR-MLX-4bit - [speech-swift](https://github.com/soniqo/speech-swift) — Apple SDK - [soniqo.audio](https://soniqo.audio) — website - [blog](https://soniqo.audio/blog) — blog MLX port of [AudioSR](https://github.com/haoheliu/versatile_audio_super_resolution) — a **multi-step latent-diffusion audio super-resolution model** — quantized to **INT4** weight-only for on-device inference on Apple Silicon. Upsamples any-rate input (mono) to **48 kHz** with a 200-step DDIM solver (v-prediction + classifier-free guidance) over an AudioLDM-style VAE latent, then decodes via a HiFi-GAN vocoder. AudioSR is the **teacher** model that [FlashSR](https://huggingface.co/aufklarer/FlashSR-MLX-4bit) was distilled from — FlashSR runs the same architecture in 1 step instead of 200, at the cost of some quality. ## Model | | | |---|---| | Total parameters | 672 M (VAE 223 M + UNet 258 M + Vocoder 190 M) | | Diffusion | 200-step DDIM, v-prediction, cosine schedule, η=0 | | Classifier-free guidance | scale 3.5 (cond + uncond passes per step) | | Quantization | INT4 weight-only, group size 64, mode `mlx_affine_flat` | | Format | MLX safetensors (single combined bundle) | | Sample rate | 48 kHz mono out (any-rate mono in) | | Frame length | 10.24 s (491 520 samples) per forward | | Bundle size | 365 MB on disk | | Source | [haoheliu/audiosr_basic](https://huggingface.co/haoheliu/audiosr_basic) | ## Files | File | Size | Description | |---|---|---| | `model.safetensors` | 365 MB | INT4-quantized VAE + UNet + HiFi-GAN weights | | `config.json` | ~80 KB | Sub-model configs + quantization metadata + per-tensor shape table for dequant-on-load | The three sub-models share one safetensors file with `vae.*`, `ldm.*`, `voc.*` key prefixes. `config.quantized_shapes` records each tensor's pre-flatten shape so `mx.dequantize` can rebuild conv weight tensors at load time. ## Performance (Apple Silicon, M-series, 10.24 s @ 48 kHz) | Metric | Value | |---|---| | Real-time factor (wall / audio) | **1.87** | | Load time | 0.06 s | | SNR vs FP16 reference | **+29.2 dB** | | Peak amplitude | 0.500 (renormalised per upstream) | AudioSR is markedly slower than FlashSR (RTF 1.87 vs FlashSR's 1.10 on the same hardware) because the 200-step DDIM is the inherent bottleneck. Choose AudioSR when the teacher's quality is preferred; choose FlashSR for real-time on-device use. ## Usage ```python from huggingface_hub import snapshot_download import mlx.core as mx import numpy as np import scipy.io.wavfile as wf from scipy.signal import resample_poly bundle = snapshot_download("aufklarer/AudioSR-MLX-4bit") # See https://github.com/soniqo/speech-swift for production usage. # Toy Python demo (requires the matching MLX AudioSR runtime): sr, audio = wf.read("lr.wav") audio = audio.astype(np.float32) / 32767.0 audio_48 = resample_poly(audio, 48000, sr).astype(np.float32) from audiosr import AudioSR model = AudioSR(bundle) hr = model(mx.array(audio_48), steps=200, cfg_scale=3.5, seed=42) mx.eval(hr) wf.write("hr.wav", 48000, (np.clip(np.array(hr), -1, 1) * 32767).astype(np.int16)) ``` ## Source - Upstream: [haoheliu/audiosr_basic](https://huggingface.co/haoheliu/audiosr_basic) - Paper: [AudioSR: Versatile Audio Super-resolution at Scale](https://arxiv.org/abs/2309.07314) - Distilled student (1-step): [FlashSR](https://github.com/jakeoneijk/FlashSR_Inference) ## License **CC-BY-NC 4.0** — inherited from upstream AudioSR weights. Non-commercial use only.