spleeter icon indicating copy to clipboard operation
spleeter copied to clipboard

Node/Electron version

Open pietrop opened this issue 5 years ago • 27 comments

Description

This looks awesome, is there a way to use it as a node module? (eg via npm) packaged in such a away to be able to use it in an electron app?

Additional information

Thinking of adding it as an option to autoEdit.io to clean audio before sending it to a Speech To Text Enginge.

pietrop avatar May 05 '20 18:05 pietrop

Hi @pietrop

There's no out of the box node module made on top of spleeter that I know of.

Theoretically it's feasible to build a javascript lib out of spleeter, you'd need to use the tensorflow.js port to load the models though.

An easier possibility would be to host a small webservice serving spleeter and requesting it through js I guess.

mmoussallam avatar May 10 '20 12:05 mmoussallam

Theoretically it's feasible to build a javascript lib out of spleeter

Could you kindly elaborate more? does this mean porting spleeter python code to js?

ibinti avatar May 22 '20 17:05 ibinti

We are about to release a js framework with all the required pre and postprocessing soon. Stay tuned

faroit avatar May 24 '20 19:05 faroit

@faroit I’ve just started working on a Spleeter “port” on top of TFJS for consumption in electron apps. Would love to contribute however I can - let me know if there’s interest in external contributions pre release!

t3dotgg avatar May 25 '20 04:05 t3dotgg

Thanks for your great work on this! 🙏 I'm very interested in a TFJS version as well and am looking forward to this upcoming release!!!

skratchdot avatar Jun 13 '20 11:06 skratchdot

@faroit any news?

chenei avatar Jun 28 '20 07:06 chenei

@chenei we are updating the framework to support tf 2.2. ETA next two weeks. @TheoBr we could could for sure get some help. We only implemented the pre- and postprocessing. So the spleeter spectrogram core model would need to be converted to tfjs (as we add open-unmix for now). The last time I tried it was not compatible out of the box and required manual layer patching.

faroit avatar Jun 28 '20 09:06 faroit

@TheoBr Hi, Can I help u somehow?

chenei avatar Jun 28 '20 14:06 chenei

@chenei I have not gotten started on any work related to Spleeter in Node :( Would love an update or even a WIP branch to work against if at all possible @faroit

t3dotgg avatar Jul 13 '20 18:07 t3dotgg

@faroit any news?

AdrianButnar avatar Aug 19 '20 21:08 AdrianButnar

@AdrianButnar @TheoBr sorry for the slow response. We managed to get the full open-unmix and spleeter models working. If any of you are js devs, we would love some feedback. Send me a mail please

faroit avatar Sep 09 '20 07:09 faroit

@faroit thanks for your past update and work on TF.js version of spleeter! is there a timeline for when code and/or artifacts will be released?

Syps avatar Oct 07 '20 01:10 Syps

@faroit is this still a thing? Has support been dropped?

theblissprogrammer avatar Nov 12 '20 13:11 theblissprogrammer

@theblissprogrammer @Syps @AdrianButnar @TheoBr sorry for the long delay. We have working models but we are currently working on speeding up inference and reduce memory usage.

See a W.I.P site here (currently only open-unmix works) https://sigsep.github.io/open-unmix-js/

We will open the repo very soon and can't wait to get some help from javascript gurus ;-)

faroit avatar Nov 12 '20 14:11 faroit

Just to let you know, I just tried a Open-Unmix vocal separation & the processing bar circle just spun for several minutes with no results.

Roger

 On Thursday, November 12, 2020, 08:05:23 AM CST, Fabian-Robert Stöter <[email protected]> wrote:  

@theblissprogrammer @Syps @AdrianButnar @TheoBr sorry for the long delay. We have working models but we are currently working on speeding up inference and reduce memory usage.

See a W.I.P site here (currently only open-unmix works) https://sigsep.github.io/open-unmix-js/

We will open the repo very soon and can't wait to get some help from javascript gurus ;-)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Mixerrog avatar Nov 12 '20 14:11 Mixerrog

Just to let you know, I just tried a Open-Unmix vocal separation & the processing bar circle just spun for several minutes with no results. Roger On Thursday, November 12, 2020, 08:05:23 AM CST, Fabian-Robert Stöter

same thing happened with the file i tried. it was a 4 minute mp3 and i let it spin for more than 20 minutes with no result.

i figured i'd give feedback as well (just in case it helps).

good luck with the speed/memory improvements and thanks for all your work @faroit!

skratchdot avatar Nov 12 '20 15:11 skratchdot

@Mixerrog @skratchdot yes. RAM is an issue in long files. For now:

  • use chrome
  • try <30s files

Please wait until we open the repo for reports as this is out of scope for spleeter. ( Or just drop me a mail)

faroit avatar Nov 12 '20 16:11 faroit

Thanks you for this amazing project. Look forward for JS version :)

hthieu1110 avatar Nov 16 '20 10:11 hthieu1110

I've been able to use spleeter it in my Node.js application with Python Shell along with node-wget.

amamenko avatar Jul 26 '21 03:07 amamenko

@amamenko Could you elaborate pls with a snippet for the command line you're passing? It's about an open source project I'm working on

kyr0 avatar Sep 06 '21 15:09 kyr0

@kyr0 Sure, so I have a couple of Python scripts in separate files that are both executed by the Node.js python-shell module.

The first file is called "install_package.py," which takes an argument and downloads Python packages accordingly:

import os
import sys
 
os.system('python3 -m pip install {}'.format(sys.argv[1]))

The second file is called "spleeter_stems.py," which takes an argument and runs Spleeter on that argument file via the command line:

import os
import sys

os.system('spleeter separate -p spleeter:2stems -o output {} -c mp3'.format(sys.argv[1]))

A basic Node.js example using python-shell and node-wget with these two Python scripts looks something like this:

const fs = require("fs");
const wget = require("node-wget");
const { PythonShell } = require("python-shell");

wget("https://github.com/deezer/spleeter/raw/master/audio_example.mp3", () => {
  const filePath = "audio_example.mp3";

  // Make sure Spleeter is installed
  PythonShell.run(
    "./python_scripts/install_package.py",
    { args: ["spleeter"] },
    (err) => {
      if (err) {
        throw err;
      } else {
        console.log("Splitting audio file.");
        // Get audio file
        const spleeterOptions = {
          args: ["audio_example.mp3"],
        };

        // Split audio into stems and clean up
        PythonShell.run(
          "./python_scripts/spleeter_stems.py",
          spleeterOptions,
          (err) => {
            if (err) {
              throw err;
            } else {
              console.log("Successfully split track into two stems");
              fs.unlinkSync(filePath);
              fs.rmSync("pretrained_models", { recursive: true });
              console.log(
                "Removed pretrained_models directory and local audio file"
              );
            }
          }
        );
      }
    }
  );
});

amamenko avatar Sep 08 '21 04:09 amamenko

@amamenko Wow, nice, thank you Avi! This is perfect, I'll play with it this weekend and see if I can quickly come up with a general purpose UI solution for all OS

kyr0 avatar Sep 08 '21 07:09 kyr0

@amamenko i used your code and it's working very good thanks

Mersal-Mohamed avatar Nov 14 '21 21:11 Mersal-Mohamed

Hey @faroit @TheoBr, just checking on updates for the tf.js port or any JS version released for the spleeter module.

Is there anything along the lines in progress or in backlog? Thanks!

kumar1202 avatar Feb 10 '22 16:02 kumar1202

Hey @faroit @TheoBr, just checking on updates for the tf.js port or any JS version released for the spleeter module.

Is there anything along the lines in progress or in backlog? Thanks!

No update on that. We released the umxjs code and all four stem models.

faroit avatar Feb 10 '22 16:02 faroit

@kyr0 Sure, so I have a couple of Python scripts in separate files that are both executed by the Node.js python-shell module.

The first file is called "install_package.py," which takes an argument and downloads Python packages accordingly:

import os
import sys
 
os.system('python3 -m pip install {}'.format(sys.argv[1]))

The second file is called "spleeter_stems.py," which takes an argument and runs Spleeter on that argument file via the command line:

import os
import sys

os.system('spleeter separate -p spleeter:2stems -o output {} -c mp3'.format(sys.argv[1]))

A basic Node.js example using python-shell and node-wget with these two Python scripts looks something like this:

const fs = require("fs");
const wget = require("node-wget");
const { PythonShell } = require("python-shell");

wget("https://github.com/deezer/spleeter/raw/master/audio_example.mp3", () => {
  const filePath = "audio_example.mp3";

  // Make sure Spleeter is installed
  PythonShell.run(
    "./python_scripts/install_package.py",
    { args: ["spleeter"] },
    (err) => {
      if (err) {
        throw err;
      } else {
        console.log("Splitting audio file.");
        // Get audio file
        const spleeterOptions = {
          args: ["audio_example.mp3"],
        };

        // Split audio into stems and clean up
        PythonShell.run(
          "./python_scripts/spleeter_stems.py",
          spleeterOptions,
          (err) => {
            if (err) {
              throw err;
            } else {
              console.log("Successfully split track into two stems");
              fs.unlinkSync(filePath);
              fs.rmSync("pretrained_models", { recursive: true });
              console.log(
                "Removed pretrained_models directory and local audio file"
              );
            }
          }
        );
      }
    }
  );
});

Did anyone manage to get this implementation working? Getting errors about the pretrained_models missing. But even before that the result from running the PythonShell is null.

tobyonono avatar Nov 05 '22 01:11 tobyonono