C++ runtime for LavaSR using ONNX Runtime.
This implementation runs the LavaSR pipeline in C++ with ONNX Runtime and custom DSP utilities implemented in main.cpp. The current pipeline supports:
- mono WAV input
- optional denoising with the ULUNAS ONNX denoiser
- 16 kHz to 48 kHz resampling
- enhancement with the ONNX backbone and ONNX spectrogram head
- WAV output at 48 kHz
The program uses three ONNX models at runtime:
denoiser_core_legacy_fixed63.onnxenhancer_backbone.onnx(andenhancer_backbone.onnx.data)enhancer_spec_head.onnx(andenhancer_spec_head.onnx.data)
The ONNX models are located here
The app reads and writes WAV files with dr_wav.h, which is an external single-file audio library from the dr_libs project by David Reid. Include the license and attribution required by that project when redistributing the repository.
Before compiling, install ONNX Runtime and make sure its CMake package is discoverable by find_package(onnxruntime REQUIRED).
You also need:
- CMake 3.14+
- a C++17 compiler
- the ONNX model files from the release page
dr_wav.hpresent in the repository root next tomain.cpp
This project’s CMakeLists.txt expects ONNX Runtime to be installed already and links against onnxruntime::onnxruntime.
Download the required ONNX files from the release page:
Place the ONNX files and any matching .onnx.data sidecar files in the same directory as the executable, or pass explicit paths through the CLI arguments.
Expected runtime model files:
denoiser_core_legacy_fixed63.onnxenhancer_backbone.onnxenhancer_backbone.onnx.dataenhancer_spec_head.onnxenhancer_spec_head.onnx.data
A minimal layout is:
LavaSRcpp/
├── CMakeLists.txt
├── main.cpp
├── dr_wav.h
├── denoiser_core_legacy_fixed63.onnx
├── enhancer_backbone.onnx
├── enhancer_backbone.onnx.data
├── enhancer_spec_head.onnx
├── enhancer_spec_head.onnx.data
└── build/
If you keep the ONNX files elsewhere, pass their paths with the CLI flags.
Example build steps:
mkdir build
cd build
cmake ..
cmake --build . --config ReleaseIf CMake cannot find ONNX Runtime automatically, point it to your ONNX Runtime installation using the appropriate CMake variable or prefix path for your platform.
Basic usage:
./lavasr input.wavWrite to a specific output file:
./lavasr input.wav -o output.wavEnable denoising:
./lavasr input.wav -o output.wav --denoisePass explicit model paths:
./lavasr input.wav \
--denoise \
--denoiser-onnx /path/to/denoiser_core_legacy_fixed63.onnx \
--enhancer-backbone-onnx /path/to/enhancer_backbone.onnx \
--enhancer-spec-head-onnx /path/to/enhancer_spec_head.onnx \
-o output.wav- Input is read as WAV and mixed to mono if needed.
- Audio is resampled internally to 16 kHz for denoising and 48 kHz for enhancement.
- Output is written as 32-bit float mono WAV at 48 kHz.
- The DSP pipeline in
main.cppincludes custom FFT, STFT/ISTFT, mel frontend, resampling, and final spectral merge.