Curly-Mo / swingify

Make any song swing
https://musinformatics.com/swingify
MIT License
9 stars 4 forks source link

time_stretch() takes 1 positional argument but 2 were given #5

Open Wintar opened 1 year ago

Wintar commented 1 year ago

Running on Python 3.10.10 Here is the full error:

(2, 3533824)
Traceback (most recent call last):
  File "E:\Downloads\swingify-master\swingify.py", line 172, in <module>
    swingify(args.audio_path, args.output, args.factor, format=args.format)
  File "E:\Downloads\swingify-master\swingify.py", line 22, in swingify
    output = synthesize(raw_samples, beats, factor)
  File "E:\Downloads\swingify-master\swingify.py", line 61, in synthesize
    left = timestretch(left, factor1)
  File "E:\Downloads\swingify-master\swingify.py", line 117, in timestretch
    left = librosa.effects.time_stretch(signal[0, :], factor)
TypeError: time_stretch() takes 1 positional argument but 2 were given

Here are the inputs that cause the error:

.\swingify.py -f 2.0 --format .mp3 .\fight.mp3 .\swung.mp3
.\swingify.py --format .mp3 .\fight.mp3 .\swung.mp3
.\swingify.py .\fight.mp3 .\swung.mp3
.\swingify.py .\fight.mp4 .\swung.mp3

Changing the directory of the files also did not change the error.

pjkitsune commented 11 months ago

Getting the exact same error. Tried my best to work at fixing it, but got nowhere.

Gumberly commented 5 months ago

The following fixed the issue for me (I'm using librosa 0.10.2 and Python 3.10.12):

Inside the timestretch function definition, add "rate=" to the 2nd argument of time_stretch() as shown below:

    left = librosa.effects.time_stretch(signal[0, :], rate=factor)
    right = librosa.effects.time_stretch(signal[1, :], rate=factor)

This is in accordance with the usage of time_stretch() shown in librosa's documentation (https://librosa.org/doc/latest/generated/librosa.effects.time_stretch.html).