From b792f0715413fb3b125014064e327fe32c14b069 Mon Sep 17 00:00:00 2001 From: Ma5onic <18509613+Ma5onic@users.noreply.github.com> Date: Sat, 13 Apr 2024 05:14:32 -0400 Subject: [PATCH 1/5] Fix Tempo Error - `TypeError: unsupported format string passed to numpy.ndarray.__format__` --- tools/automix.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/automix.py b/tools/automix.py index a839345e..b1086dd2 100644 --- a/tools/automix.py +++ b/tools/automix.py @@ -205,12 +205,18 @@ def find_candidate(spec_ref, catalog, pitch_match=True): def get_part(spec, source, dt, dp): """Apply given delta of tempo and delta of pitch to a stem.""" wav = spec.track[source] - if dt or dp: - wav = repitch(wav, dp, dt * 100, samplerate=SR, voice=source == 3) + if dt != 0 or dp != 0: # Check if there's any change to apply + # Ensure 'dt' is a scalar if it's an array + if isinstance(dt, np.ndarray) and dt.size == 1: + dt = float(dt.item()) # Convert numpy array to Python scalar + # Convert tempo change from relative change (e.g., -0.12 for 88%) to percentage change expected by `repitch` + tempo_percentage_change = dt * 100 # Convert to percentage (e.g., -12 for 88% speed) + # Apply pitch and tempo changes + wav = repitch(wav, dp, tempo_percentage_change, voice=source == 3, samplerate=SR) + # Adjust onsets according to new tempo spec = spec._replace(onsets=spec.onsets / (1 + dt)) return wav, spec - def build_track(ref_index, catalog): """Given the reference track index and a catalog of track, builds a completely new track. One of the source at random from the ref track will From f1254ce9902071530b07aace31371b3fc29b4612 Mon Sep 17 00:00:00 2001 From: Ma5onic <18509613+Ma5onic@users.noreply.github.com> Date: Sat, 13 Apr 2024 05:33:46 -0400 Subject: [PATCH 2/5] Bump librosa to `0.10.2-release` branch This fixes `AttributeError: module 'scipy.signal' has no attribute 'hann'` that occurs when trying to augment data using `automix.py`. In librosa version 0.10.2.dev0, the `__trim_beats` in beat.py no longer uses scipy for hanning computation & now uses `np.hanning` instead. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 294290d3..d1cb5e16 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,3 +17,4 @@ torchaudio>=0.8,<2.1 tqdm treetable soundfile>=0.10.3;sys_platform=="win32" +librosa @ git+https://github.com/librosa/librosa.git@c0266e4 From 8b4290427d47a6dc1f6078a2d08ccf5a054b2707 Mon Sep 17 00:00:00 2001 From: Ma5onic <18509613+Ma5onic@users.noreply.github.com> Date: Sat, 13 Apr 2024 21:00:20 -0400 Subject: [PATCH 3/5] Update librosa to build from source master branch inrequirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d1cb5e16..8c238d48 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,4 @@ torchaudio>=0.8,<2.1 tqdm treetable soundfile>=0.10.3;sys_platform=="win32" -librosa @ git+https://github.com/librosa/librosa.git@c0266e4 +librosa @ git+https://github.com/librosa/librosa.git From fc17f8b77c854ddf2ccd891058d6597921ebb13a Mon Sep 17 00:00:00 2001 From: Ma5onic <18509613+Ma5onic@users.noreply.github.com> Date: Wed, 24 Apr 2024 10:47:29 -0400 Subject: [PATCH 4/5] Fix install instructions for machine learning scientists Fix README.md instructions for machine learning scientists, so that the training requirements/dependencies actually get installed. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe7e77b9..6c7a5f27 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ If you have anaconda installed, you can run from the root of this repository: conda env update -f environment-cpu.yml # if you don't have GPUs conda env update -f environment-cuda.yml # if you have GPUs conda activate demucs -pip install -e . +pip install -e .[dev] ``` This will create a `demucs` environment with all the dependencies installed. From 46a5090757eb1629f2c5c3a46c64d48a51eed555 Mon Sep 17 00:00:00 2001 From: Ma5onic <18509613+Ma5onic@users.noreply.github.com> Date: Wed, 24 Apr 2024 16:25:17 -0400 Subject: [PATCH 5/5] Removed typo in my comments `-12` should have been `-0.12` but the comment was redundant, so I removed it. --- tools/automix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/automix.py b/tools/automix.py index b1086dd2..5a324f1b 100644 --- a/tools/automix.py +++ b/tools/automix.py @@ -210,7 +210,7 @@ def get_part(spec, source, dt, dp): if isinstance(dt, np.ndarray) and dt.size == 1: dt = float(dt.item()) # Convert numpy array to Python scalar # Convert tempo change from relative change (e.g., -0.12 for 88%) to percentage change expected by `repitch` - tempo_percentage_change = dt * 100 # Convert to percentage (e.g., -12 for 88% speed) + tempo_percentage_change = dt * 100 # Convert to percentage # Apply pitch and tempo changes wav = repitch(wav, dp, tempo_percentage_change, voice=source == 3, samplerate=SR) # Adjust onsets according to new tempo