I'm using this Spleeter library for vocal seperation Spleeter-Android-iOS
But it gives me 1 instead of 0 when I call the func spleeterSDK.process(wavPath!, outPath: path). I don't know what is the problem.
Any help will be appreciated
let ret = spleeterSDK.process(wavPath!, outPath: path) // here the ret should be zero
if(ret == 0) {
let queue = DispatchQueue(label: "process-queue")
queue.async {
while(true) {
let progress = self.spleeterSDK.progress()
DispatchQueue.main.async {
self.progress.text = String(progress) + "%"
}
usleep(1000 * 1000);
if(progress == 100) {
break
}
}
self.spleeterSDK.saveOne(url.path + "/record.wav", stemRatio: UnsafeMutablePointer<Float32>(mutating: self.stemRatio))
DispatchQueue.main.async {
self.btnProcess.isEnabled = true
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
try AVAudioSession.sharedInstance().setActive(true)
self.player = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: path + "/record.wav"))
guard let player = self.player else {
return
}
player.play()
} catch let error {
print(error.localizedDescription)
}
}
}
}
Update:
how I'm creating SDK
spleeterSDK = SpleeterSDK();
let ret = spleeterSDK.createSDK()
spleeterSDK.release()
print("create SDK: ", ret) // Here it prints 2
This is the way I'm using to get wav wavPath
let wavPath = Bundle.main.path(forResource: "_input.wav", ofType: nil)
This is the way I'm using to get wav outPath
let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
print(url.path)
let path = url.path