Downloads · 30 days
0
babybirdprd/novasr-candle
novasr-candle is a machine learning model from babybirdprd. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
A Rust port of NovaSR - a lightning-fast audio super-resolution model - using Hugging Face Candle.
Downloads · 30 days
0
Access
Public
Updated Jan 28, 2026
Repo size
94.5 KB
Likes
0
Public
Click a slice to open those files.
.safetensors94.5 KB · 92%
From the Hugging Face model README
A Rust port of NovaSR - a lightning-fast audio super-resolution model - using Hugging Face Candle.
NovaSR is a tiny 52KB model that upsamples 16kHz audio to crystal-clear 48kHz at speeds exceeding 3600x realtime. This project ports the original PyTorch implementation to Rust using the Candle deep learning framework.
Input (16kHz) → ConvPre → Interpolate (3x) → AMPBlock0 → ConvPost → Tanh → Output (48kHz)
SnakeBeta Activation: Novel activation function for periodic signals
x + (1 - cos(2 * α * x)) / (2 * β + ε)
AMPBlock0: Residual block with dilated convolutions and SnakeBeta activation
Generator: Main upsampling network with pre/post convolutions
├── src/ │ ├── lib.rs # Core library │ └── main.rs # CLI tool ├── models/ # Safetensors weights ├── scripts/ # Utility scripts (conversion, parity) ├── data/ # Audio samples ├── Cargo.toml └── README.md
# Clone the repository
git clone <repo-url>
cd novasr-candle
# Build the library and CLI
cargo build --release
# The binary will be at target/release/novasr-cli
First, convert the PyTorch weights to Candle format:
uv run --project NovaSR python scripts/convert_weights.py \
--input novasr_model.pth \
--output models/novasr_v1.safetensors
# Upsample an audio file using a local model
./target/release/novasr-cli input.wav output.wav models/novasr_v1.safetensors
# Upsample using a model from Hugging Face Hub
./target/release/novasr-cli input.wav output.wav babybirdprd/novasr-candle
use candle_core::{Device, DType};
use candle_nn::VarBuilder;
use novasr_candle::{load_model, upsample_audio};
fn main() -> anyhow::Result<()> {
let device = Device::Cpu;
// Load from HF Hub
let model = novasr_candle::from_hf("babybirdprd/novasr-candle", "main", &device)?;
// OR load local
// let vb = unsafe { VarBuilder::from_mmaped_safetensors("model.safetensors", DType::F32, &device)? };
// let model = load_model(vb)?;
// Process audio
let input = candle_core::Tensor::from_vec(
audio_samples,
(1, 1, sample_count),
&device,
)?;
let output = upsample_audio(&model, &input)?;
Ok(())
}
The SnakeBeta activation is a learnable periodic activation function:
pub fn forward(&self, x: &Tensor) -> Result<Tensor> {
let a = self.alpha.exp()?;
let b = self.beta.exp()?;
// x + (1 - cos(2 * alpha * x)) / (2 * beta + epsilon)
let two_a_x = (x.broadcast_mul(&a)? * 2.0)?;
let cos_term = two_a_x.cos()?;
let one_minus_cos = (Tensor::ones_like(&cos_term)? - cos_term)?;
let inv_2b = ((b * 2.0)? + 1e-9)?.recip()?;
x.add(&one_minus_cos.broadcast_mul(&inv_2b)?)
}
The Generator performs the main upsampling:
| Property | Value |
|---|---|
| Total Parameters | ~13,000 |
| Model Size | 52 KB |
| Input Sample Rate | 16 kHz |
| Output Sample Rate | 48 kHz |
| Upsampling Factor | 3x |
| Inference Speed | 3600x realtime (A100) |
| Feature | PyTorch (Original) | Candle (This Port) |
|---|---|---|
| Language | Python | Rust |
| Framework | PyTorch | Candle |
| Dependencies | Heavy | Minimal |
| WASM Support | No | Yes |
| Performance | Fast | Comparable |
A web demo showcasing the model architecture and Rust implementation is available at:
https://vkf4cascsh44i.ok.kimi.link
Apache 2.0 - Same as the original NovaSR project