A C++ implementation for inference of Deej‑AI models using ONNX Runtime.
deej‑ai.cpp is designed to be portable so the onnx runtime is bundled in the build. Running CMake will download Eigen and the prebuild ONNX Runtime. The only external requirement is the ffmpeg executable. The playlist generation is much faster than the python version, the scan is also quite faster.
- C++20
- CMake ≥ 3.15
- Ninja
- ffmpeg
Linux:
git clone https://github.com/StergiosBinopoulos/deej-ai.cpp
cd deej-ai.cpp
cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
ninja -C build deej-aiMacOS (Universal):
cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
ninja -C build deej-aiOn Windows I suggest using MinGW and gcc:
cmake -B build -G Ninja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release
ninja -C build deej-aiTo get a portable package build the package target instead:
ninja -C build packageThe bundle is exported in the package folder. Use target package_zip to also zip the output.
To build statically on Windows, you will need Visual Studio 2022 and Git Bash. Open Git Bash, navigate to the root directory, and run the following commands:
git clone https://github.com/supertone-inc/onnxruntime-build.git onnxruntime-build
cd onnxruntime-build
git checkout v1.22.2
./build-static_lib.sh
cd ..after the onnxruntime static library build is completed you can configure the project and build:
cmake -B build_static -G "Visual Studio 17 2022" -DSTATIC_BUILD=ON
cmake --build build_static --target deej-ai --config Release
# or
# cmake --build build_static --target package --config ReleaseYou can download a ready to go ONNX deej-ai model or use the scipts in the Deej-AI repository to convert your existing model to ONNX.
curl -L https://huggingface.co/StergiosBinopoulos/deej-ai.onnx/resolve/main/deej-ai.onnx?download=true --output deej-ai.onnxMake sure you have ffmpeg installed
sudo apt update
sudo apt install ffmpegIf you are using Windows, download ffmpeg and add it to your PATH, or specify your ffmpeg executable path by using the --ffmpeg argument.
Scan your music folder(s). Replace <music_folder> with the folder you like to scan. Adjust the name of the vectors directory accordingly.
build/bin/deej-ai --model deej-ai.onnx --scan <music_folder_1> --scan <music_folder_2> --vec-dir test_folderExample 1: Append 15 songs at the end of the input. (This will print the output)
build/bin/deej-ai --generate append --input <path_of_song_1> --input <path_of_song_2> ... --nsongs 15 --vec-dir test_folderTo save the output in m3u file use --m3u-out or -o:
build/bin/deej-ai --generate append --input <path_of_song_1> --input <path_of_song_2> ... --nsongs 15 --vec-dir test_folder --m3u-out playlist.m3uExample 2: Connect your input songs with 6 songs inbetween them:
build/bin/deej-ai --generate connect --input <path_of_song_1> --input <path_of_song_2> --nsongs 6 --vec-dir test_folderExample 3: Append 20 songs. Only determine the playlist from the original cluster of input songs.
build/bin/deej-ai --generate cluster --input <path_of_song_1> --input <path_of_song_2> --nsongs 20 --vec-dir test_folderExample 4: Reorder an existing playlist to improve the listening experience.
build/bin/deej-ai --reorder --input <path_of_song_1> --input <path_of_song_2> ... --first <path_of_song_1>Use -h to view all options:
build/bin/deej-ai -h