I'm using this Spleeter library for vocal seperation but it is not working

366 views Asked by At

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
1

There are 1 answers

1
Lou Franco On

Generally, if a function works, it has requirements on its inputs. We would need to see your inputs to have any chance to know why it doesn't work

spleeterSDK.process(wavPath!, outPath: path)
  1. What is wavPath?
  2. Is there actually a file there on your device in a place your app can see it?
  3. Is it a wav formatted file?
  4. What does it have in it?
  5. what is path?
  6. is it a valid path?
  7. Does the folder it reference exist? Do you have permission to write to it?
  8. Does spleeterSDK require that you call any other functions before process would work (an initialization?)
  9. The demo code says you need to call ret = spleeterSDK.createSDK() -- did you do that? If so, what did it return?
  10. Did you run their demo app? Did it work?

You should verify that you checked all of those things.