1

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
Aarfeen Ahmad
  • 76
  • 1
  • 8
  • I also tried to use the library and it wasnt working. So apparently, i contacted the owner and he said the sdk is not free. It costs 7k USD. – Ismail Osunlana May 01 '23 at 08:56

1 Answers1

1

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.

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
  • I think it’s pretty unlikely that you are supposed to call `spleeterSDK.release()` — I don’t see that in their demo. – Lou Franco Aug 25 '22 at 12:03