deezer / deezer/spleeter

[Bug] looping over files will cause a race condition

Open
#815 2 comments 0 reactions 0 assignees View on GitHub
bug invalid
Dominant language
Python
Stars
28.4k
Forks
3.1k
PR merge metrics
No merged PRs in 30d

Description

- [x] I didn't find a similar issue already open.
- [x] I read the documentation (README AND Wiki)
- [x] I have installed FFMpeg
- [x] My problem is related to Spleeter only, not a derivative product (such as Webapplication, or GUI provided by others)

## Description
when looping over audio files, do separation and save will cause a race condition. e.g. file1, file2, file3 after feeding to separater will give file2, file2, file1. I tried setting the multiprocessing to false and tried using separator.separate_to_file(), none worked, same behaviour

## Step to reproduce

```
from spleeter.separator import Separator
from spleeter.audio.adapter import AudioAdapter
from scipy.io.wavfile import write

separator = Separator('spleeter:2stems', multiprocess=False) # two parts output, vocals and accompanying noise
audio_loader = AudioAdapter.default()

def extract_vocals(input_dir, sampling_rate, rm_original=False):
toprocess = []
for root, dirs, files in os.walk(input_dir):
for file in files:
if file.endswith(('.wav', '.flac', '.m4a', '.mp3')):
toprocess.append(Path(root) / file)

for pt in tqdm(toprocess, unit='files'):
waveform, _ = audio_loader.load(fpath, sample_rate=sampling_rate)
prediction = separator.separate(waveform)
vocals = librosa.to_mono(prediction['vocals'].T)
write(str(fpath)[:-4] + '_vocals.wav', sampling_rate, vocals)
if rm_original:
os.remove(fpath)

extract_vocals('input_folder', 16000, False)

```

Contributor guide

Open the contributing guide

Research direction

Reproduce the loop shown in the issue, then inspect spleeter.separator.Separator.separate and the AudioAdapter loading path for state that could associate outputs with the wrong input. Done means processing file1, file2, and file3 consistently writes each file's vocals to its own output; add or run a regression check if the repository provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
audio-video-rtc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.