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

@@ -4,10 +4,13 @@
#include "sherpa-onnx/csrc/offline-source-separation-model-config.h"
#include "sherpa-onnx/csrc/macros.h"
namespace sherpa_onnx {
void OfflineSourceSeparationModelConfig::Register(ParseOptions *po) {
spleeter.Register(po);
uvr.Register(po);
po->Register("num-threads", &num_threads,
"Number of threads to run the neural network");
@@ -20,7 +23,17 @@ void OfflineSourceSeparationModelConfig::Register(ParseOptions *po) {
}
bool OfflineSourceSeparationModelConfig::Validate() const {
return spleeter.Validate();
if (!spleeter.vocals.empty()) {
return spleeter.Validate();
}
if (!uvr.model.empty()) {
return uvr.Validate();
}
SHERPA_ONNX_LOGE("Please specify a source separation model");
return false;
}
std::string OfflineSourceSeparationModelConfig::ToString() const {
@@ -28,6 +41,7 @@ std::string OfflineSourceSeparationModelConfig::ToString() const {
os << "OfflineSourceSeparationModelConfig(";
os << "spleeter=" << spleeter.ToString() << ", ";
os << "uvr=" << uvr.ToString() << ", ";
os << "num_threads=" << num_threads << ", ";
os << "debug=" << (debug ? "True" : "False") << ", ";
os << "provider=\"" << provider << "\")";