Open Ma5onic opened 5 months ago
@CarlGao4 Thanks for the feedback. Sorry I missed the part in the readme about adefossezs' fork. I was just following the CONTRIBUTING.md which states:
Demucs is the implementation of a research paper. Therefore, we do not plan on accepting many pull requests for new features. We certainly welcome them for bug fixes.
This is a bug fix and not a pull request for a new feature, which is why I opened this PR.
As for the requirements.txt
, could you explain why I shouldn't be placing librosa in it when the "Requirements" section of README.md states:
See
requirements_minimal.txt
for requirements for separation only, andenvironment-[cpu|cuda].yml
(orrequirements.txt
) if you want to train a new model.
This can be confirmed by inspecting the setup.py
used by pip
, which shows that the that the requirements_minimal.txt
is used by default and the requirements.txt
is only used if you specify [dev]
during the installation (either with pip install -e .[dev]
or pip install demucs[dev]
) as seen in lines 59 to 62:
extras_require={
'dev': ALL_REQUIRED,
},
install_requires=REQUIRED,
where:
REQUIRED = load_requirements('requirements_minimal.txt')
ALL_REQUIRED = load_requirements('requirements.txt')
Sorry that's my mistake. But did you add this requirement to environment-cuda.yml
?
@CarlGao4, No problem... It happens. 😉
But did you add this requirement to
environment-cuda.yml
?
No, not yet...
Short Answer: I'm waiting for release 0.10.2
of librosa
to be distributed by pip
Long Answer:
requirements.txt
pip
or conda-forge
is 0.10.1
, which is the version that was causing the bug. When trying to locate librosa/beat.py", line 507
from the Traceback output in the master branch, I noticed that smooth_boe = scipy.signal.convolve(localscore[beats], scipy.signal.hann(5), "same")
no longer existed at its original location.smooth_boe
is currently being defined, I noticed that it now used numpy
instead of scipy.signal
. Since the new smooth_boe
implementation is what is being used in the planned 0.10.2
release, I decided to install from source instead of writing a fix that would break once version 0.10.2
of librosa
gets officially released.conda
pre-installed. Setting librosa in requirements.txt
allows it to be used using venv
+ pip
as well.conda
dependency resolver can sometimes take ridiculous amounts of time & still fail to resolve dependencies, which can be costly when using a cloud GPU instance.However, I do agree that once version 0.10.2
of librosa gets released to the pip
package manager (and/or conda), it should also be specified in the - pip:
section of environment-cuda.yml
& environment-cpu.yml
.
Technically, the values of the - pip:
requirements within the environment-*.yml
should match what is in requirements.txt
(and vice versa), which is a separate issue that I will fix in a later pull request/commit.
Hi, why do I still have this problem after I modified it the way you did?
Maybe you should upgrade Python and numpy? (Like Python 3.9 and numpy 1.25.2 which is distributed with PyPI, not conda)
Fix for repitching
TypeError: unsupported format string passed to numpy.ndarray.__format__
error:and fix for
AttributeError: module 'scipy.signal' has no attribute 'hann'
:Explanation of code changes:
Conditional Application: The check
(dt != 0 or dp != 0)
ensures thatrepitch
is only called if there is a change to be made, saving computational resources if the audio is to remain unaltered.Type and Size Validation for
dt
: It ensures that dt is a scalar by checking its type and size, which is crucial for correct format string usage in therepitch
function's command construction.Percentage Conversion: The
tempo_percentage_change
calculation transformsdt
from a decimal representation (e.g.,-0.12
for a tempo slowing to 88% of the original) into the format expected by therepitch
function (e.g.,-12
to represent the same).Application of Changes: Calls
repitch
with the correct parameters, including checking if the current track is the voice track (assumed to be at index 3).Onset Adjustment: Adjusts the
onsets
of thespec
to account for the new tempo. The onsets must be scaled by the reciprocal of(1 + dt)
because a negativedt
implies a reduction in speed (and hence longer duration between onsets).