Add C++ support for UVR models (#2269)

This commit is contained in:
Fangjun Kuang
2025-06-01 17:22:08 +08:00
committed by GitHub
parent e0ca224b76
commit 2b2788332e
35 changed files with 967 additions and 101 deletions

View File

@@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -ex
log() {
# This function is from espnet
local fname=${BASH_SOURCE[1]##*/}
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
}
if [ -z $EXE ]; then
EXE=./build/bin/sherpa-onnx-offline-source-separation
fi
echo "EXE is $EXE"
echo "PATH: $PATH"
which $EXE
log "------------------------------------------------------------"
log "Run spleeter"
log "------------------------------------------------------------"
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/source-separation-models/sherpa-onnx-spleeter-2stems-fp16.tar.bz2
tar xvf sherpa-onnx-spleeter-2stems-fp16.tar.bz2
rm sherpa-onnx-spleeter-2stems-fp16.tar.bz2
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/source-separation-models/qi-feng-le-zh.wav
$EXE \
--spleeter-vocals=sherpa-onnx-spleeter-2stems-fp16/vocals.fp16.onnx \
--spleeter-accompaniment=sherpa-onnx-spleeter-2stems-fp16/accompaniment.fp16.onnx \
--num-threads=2 \
--debug=1 \
--input-wav=./qi-feng-le-zh.wav \
--output-vocals-wav=spleeter_output_vocals.wav \
--output-accompaniment-wav=spleeter_output_accompaniment.wav
rm -rf sherpa-onnx-spleeter-2stems-fp16
log "------------------------------------------------------------"
log "Run UVR"
log "------------------------------------------------------------"
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/source-separation-models/UVR-MDX-NET-Voc_FT.onnx
$EXE \
--debug=1 \
--num-threads=2 \
--uvr-model=./UVR-MDX-NET-Voc_FT.onnx \
--input-wav=./qi-feng-le-zh.wav \
--output-vocals-wav=uvr_output_vocals.wav \
--output-accompaniment-wav=uvr_output_non_vocals.wav
rm ./UVR-MDX-NET-Voc_FT.onnx \
mkdir source-separation-wavs
mv qi-feng-le-zh.wav source-separation-wavs
mv spleeter_*.wav ./source-separation-wavs
mv uvr_*.wav ./source-separation-wavs

View File

@@ -11,6 +11,7 @@ on:
- '.github/scripts/test-kws.sh'
- '.github/scripts/test-online-transducer.sh'
- '.github/scripts/test-offline-speech-denoiser.sh'
- '.github/scripts/test-offline-source-separation.sh'
- '.github/scripts/test-online-paraformer.sh'
- '.github/scripts/test-offline-transducer.sh'
- '.github/scripts/test-offline-ctc.sh'
@@ -33,6 +34,7 @@ on:
- '.github/workflows/linux.yaml'
- '.github/scripts/test-kws.sh'
- '.github/scripts/test-offline-speech-denoiser.sh'
- '.github/scripts/test-offline-source-separation.sh'
- '.github/scripts/test-online-transducer.sh'
- '.github/scripts/test-online-paraformer.sh'
- '.github/scripts/test-offline-transducer.sh'
@@ -205,6 +207,20 @@ jobs:
overwrite: true
file: sherpa-onnx-*.tar.bz2
- name: Test offline source separation
shell: bash
run: |
du -h -d1 .
export PATH=$PWD/build/bin:$PATH
export EXE=sherpa-onnx-offline-source-separation
.github/scripts/test-offline-source-separation.sh
- uses: actions/upload-artifact@v4
with:
name: source-separation-${{ matrix.build_type }}-with-shared-lib-${{ matrix.shared_lib }}-with-tts-${{ matrix.with_tts }}
path: ./source-separation-wavs/*.wav
- name: Test offline CTC
shell: bash
run: |