Views
No views yet
This is a convenience redistribution, not the original repository. All credit for the model architecture, research, training, and weights belongs to the original authors. This repository is not affiliated with or endorsed by them.
| Authors | Jaekwon Im and Juhan Nam (KAIST) |
| Paper | FlashSR: One-step Versatile Audio Super-resolution via Diffusion Distillation (arXiv:2501.10807) |
| Demo | jakeoneijk.github.io/flashsr-demo |
| Original code | jakeoneijk/FlashSR_Inference |
| Original weights | jakeoneijk/FlashSR_weights |
Note: There are other unrelated projects also named "FlashSR" (for other super-resolution).
FlashSR/, TorchJaekwon/) and the pretrained weights (weights/) are from the original repositories linked above.enhance.py), setup.py, and this README were written independently. The code in this repository (excluding model weights) is released under the Apache License 2.0.weights/
student_ldm.pth (986 MB) - Distilled latent diffusion model
sr_vocoder.pth (599 MB) - Super-resolution vocoder
vae.pth (1.6 GB) - Variational autoencoder
FlashSR/ - Model code (from original repo)
TorchJaekwon/ - Utility library (from original repo)
Assets/ExampleInput/ - Example audio files (speech, music, sound effects)
enhance.py - Standalone inference script
setup.py - Package installer1# Clone this repository
2git clone https://huggingface.co/laion/FlashSR_One-step_Versatile_Audio_Super-resolution
3cd FlashSR_One-step_Versatile_Audio_Super-resolution
4
5# Install
6pip install -e .
7pip install einops librosa soundfile tqdm scipypython enhance.py --input Assets/ExampleInput/speech.wav --output output.wavTip: If you have a conda environment with conflicting cudnn libraries, clearLD_LIBRARY_PATHbefore running:LD_LIBRARY_PATH="" python enhance.py ...
1# Single file
2python enhance.py --input my_audio.wav --output enhanced.wav
3
4# Entire directory
5python enhance.py --input ./audio_folder/ --output ./enhanced_folder/
6
7# With lowpass filter (can help when input was not originally bandwidth-limited)
8python enhance.py --input my_audio.wav --output enhanced.wav --lowpass
9
10# Specify GPU
11CUDA_VISIBLE_DEVICES=0 python enhance.py --input my_audio.wav --output enhanced.wav1import torch
2import soundfile as sf
3import numpy as np
4from pathlib import Path
5from FlashSR.FlashSR import FlashSR
6
7WEIGHTS_DIR = Path("./weights")
8WINDOW_SIZE = 245760 # 5.12 seconds at 48 kHz
9
10# Initialize
11model = FlashSR(
12 student_ldm_ckpt_path=str(WEIGHTS_DIR / "student_ldm.pth"),
13 sr_vocoder_ckpt_path=str(WEIGHTS_DIR / "sr_vocoder.pth"),
14 autoencoder_ckpt_path=str(WEIGHTS_DIR / "vae.pth"),
15)
16model = model.to("cuda").eval()
17
18# Load and prepare audio (must be mono, 48 kHz)
19samples, rate = sf.read("input.wav", dtype="float32")
20if samples.ndim > 1:
21 samples = samples.mean(axis=1)
22
23# The model accepts exactly 245760 samples per call.
24# Pad short audio; for longer audio, see enhance.py for chunk-based processing.
25waveform = torch.from_numpy(samples).unsqueeze(0) # shape: (1, num_samples)
26n = waveform.shape[-1]
27if n < WINDOW_SIZE:
28 waveform = torch.nn.functional.pad(waveform, (0, WINDOW_SIZE - n))
29
30waveform = waveform.to("cuda")
31
32with torch.no_grad():
33 result = model(waveform, lowpass_input=False)
34
35# Trim padding and save
36result = result[:, :n].squeeze(0).cpu().numpy()
37sf.write("output.wav", result, 48000)enhance.py script handles longer audio automatically using overlapping chunks with crossfading.lowpass_input flag: Set to True if your input was not originally bandwidth-limited. This applies a lowpass filter before enhancement to better match the model's training distribution.enhance.py), setup.py, and this README are released under the Apache License 2.0.FlashSR/, TorchJaekwon/) are from the original authors' repositories linked above. Please refer to those repositories for their licensing terms.1@article{im2025flashsr,
2 title={FlashSR: One-step Versatile Audio Super-resolution via Diffusion Distillation},
3 author={Im, Jaekwon and Nam, Juhan},
4 journal={arXiv preprint arXiv:2501.10807},
5 year={2025}
6}