facebookresearch / svoice

We provide a PyTorch implementation of the paper Voice Separation with an Unknown Number of Multiple Speakers In which, we present a new method for separating a mixed audio sequence, in which multiple voices speak simultaneously. The new method employs gated neural networks that are trained to separate the voices at multiple processing steps, while maintaining the speaker in each output channel fixed. A different model is trained for every number of possible speakers, and the model with the largest number of speakers is employed to select the actual number of speakers in a given sample. Our method greatly outperforms the current state of the art, which, as we show, is not competitive for more than two speakers.
Other
1.26k stars 181 forks source link

Separation of mix wav files not working #10

Closed skwolvie closed 3 years ago

skwolvie commented 3 years ago

Hi, I tried to use the CLI interface to run the model and separate the speakers in the audio input file. I believe there are some errors in passing arguments that I do not understand.

below is the recommended code to achieve separation:

python -m svoice.separate --model_path=<path to the model> --mix_dir=<path to the dir with the mixture files> --out_dir=<path to store the separated files>

I tried it and I got following error:

Speech separation using MulCat blocks: error: the following arguments are required: model_path, out_dir

I removed -- before the argument specification and I got another error saying the model dir does not exists.

Please check the below code execution to reproduce the issue.

$ python -m svoice.separate --model_path=outputs/exp_/checkpoint.th --mix_dir=/home/sachin/Desktop/mindset/mix --out_dir=/home/sachin/Desktop/mindset/s1
usage: Speech separation using MulCat blocks [-h] [--mix_dir MIX_DIR] [--mix_json MIX_JSON] [--device DEVICE] [--sample_rate SAMPLE_RATE] [--batch_size BATCH_SIZE] [-v] model_path out_dir
Speech separation using MulCat blocks: error: the following arguments are required: model_path, out_dir

$ python -m svoice.separate model_path=outputs/exp_/checkpoint.th --mix_dir=/home/sachin/Desktop/mindset/mix --out_dir=/home/sachin/Desktop/mindset/s1
usage: Speech separation using MulCat blocks [-h] [--mix_dir MIX_DIR] [--mix_json MIX_JSON] [--device DEVICE] [--sample_rate SAMPLE_RATE] [--batch_size BATCH_SIZE] [-v] model_path out_dir
Speech separation using MulCat blocks: error: the following arguments are required: out_dir

$ python -m svoice.separate model_path=outputs/exp_/checkpoint.th --mix_dir=/home/sachin/Desktop/mindset/mix out_dir=/home/sachin/Desktop/mindset/s1
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/sachin/svoice/svoice/separate.py", line 133, in <module>
    separate(args, local_out_dir=args.out_dir)
  File "/home/sachin/svoice/svoice/separate.py", line 88, in separate
    pkg = torch.load(args.model_path)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 571, in load
    with _open_file_like(f, 'rb') as opened_file:
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 229, in _open_file_like
    return _open_file(name_or_buffer, mode)
  File "/usr/local/lib/python3.8/dist-packages/torch/serialization.py", line 210, in __init__
    super(_open_file, self).__init__(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'model_path=outputs/exp_/checkpoint.th'
$
adiyoss commented 3 years ago

Hi @skwolvie, Thanks for that! it should be python -m svoice.separate <path to the model> <path to store the separated files> --mix_dir=<path to the dir with the mixture files> same as the eval script. Fixed the readme. Let me know if that works for you now.

skwolvie commented 3 years ago

I fixed the code and removed the "--" in the arguments definition and it worked perfectly fine. Thanks!