Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mel() takes 0 positional arguments but 2 positional arguments (and 3 keyword-only arguments) were given #727

Open
WachasWps opened this issue Dec 25, 2024 · 2 comments

Comments

@WachasWps
Copy link

127.0.0.1 - - [26/Dec/2024 02:23:10] "POST /ask HTTP/1.1" 500 -
Press CTRL+C to quit
127.0.0.1 - - [26/Dec/2024 02:32:03] "OPTIONS /ask HTTP/1.1" 200 -
Using cuda for inference.
Reading video frames...
Number of frames available for inference: 1
Traceback (most recent call last):
File "C:\Users\wacha\OneDrive\Desktop\Storage\avatar wav2lip\Wav2Lip\inference.py", line 280, in
main()
File "C:\Users\wacha\OneDrive\Desktop\Storage\avatar wav2lip\Wav2Lip\inference.py", line 225, in main
mel = audio.melspectrogram(wav)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\wacha\OneDrive\Desktop\Storage\avatar wav2lip\Wav2Lip\audio.py", line 47, in melspectrogram
S = _amp_to_db(_linear_to_mel(np.abs(D))) - hp.ref_level_db
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\wacha\OneDrive\Desktop\Storage\avatar wav2lip\Wav2Lip\audio.py", line 95, in _linear_to_mel
_mel_basis = _build_mel_basis()
^^^^^^^^^^^^^^^^^^
File "C:\Users\wacha\OneDrive\Desktop\Storage\avatar wav2lip\Wav2Lip\audio.py", line 100, in _build_mel_basis
return librosa.filters.mel(hp.sample_rate, hp.n_fft, n_mels=hp.num_mels,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: mel() takes 0 positional arguments but 2 positional arguments (and 3 keyword-only arguments) were given
127.0.0.1 - - [26/Dec/2024 02:32:30] "POST /ask HTTP/1.1" 500 -

@bouldrini
Copy link

bouldrini commented Dec 27, 2024

I encounter a very similar issue when executing following command in collab:

!cd Wav2Lip && python inference.py --checkpoint_path checkpoints/wav2lip_gan.pth --face "../sample_data/test.mp4" --audio "../sample_data/test.wav"

Ill attach my collab-output:

Using cuda for inference.
Reading video frames...
Number of frames available for inference: 375
Traceback (most recent call last):
  File "/content/Wav2Lip/inference.py", line 280, in <module>
    main()
  File "/content/Wav2Lip/inference.py", line 225, in main
    mel = audio.melspectrogram(wav)
  File "/content/Wav2Lip/audio.py", line 47, in melspectrogram
    S = _amp_to_db(_linear_to_mel(np.abs(D))) - hp.ref_level_db
  File "/content/Wav2Lip/audio.py", line 95, in _linear_to_mel
    _mel_basis = _build_mel_basis()
  File "/content/Wav2Lip/audio.py", line 100, in _build_mel_basis
    return librosa.filters.mel(hp.sample_rate, hp.n_fft, n_mels=hp.num_mels,
TypeError: mel() takes 0 positional arguments but 2 positional arguments (and 3 keyword-only arguments) were given

CallStack might be different - but at the bottom line both errors are thrown by Method librosa.filters.mel in "/content/Wav2Lip/audio.py", line 100.

Librosa Package is installed a couple Collab-steps before:

!cd Wav2Lip && pip install -r requirements.txt
Collecting librosa==0.7.0 (from -r requirements.txt (line 1))
  Downloading librosa-0.7.0.tar.gz (1.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 32.9 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting numpy==1.17.1 (from -r requirements.txt (line 2))
  Downloading numpy-1.17.1.zip (6.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.5/6.5 MB 64.3 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: opencv-contrib-python>=4.2.0.34 in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 3)) (4.10.0.84)
ERROR: Ignored the following yanked versions: 3.4.11.39, 3.4.17.61, 4.4.0.42, 4.4.0.44, 4.5.4.58, 4.5.5.62, 4.7.0.68
ERROR: Could not find a version that satisfies the requirement opencv-python==4.1.0.25 (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.63, 3.4.18.65, 4.3.0.38, 4.4.0.40, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.60, 4.5.5.64, 4.6.0.66, 4.7.0.72, 4.8.0.74, 4.8.0.76, 4.8.1.78, 4.9.0.80, 4.10.0.82, 4.10.0.84)
ERROR: No matching distribution found for opencv-python==4.1.0.25

A new Version might be the reason for a interface change of librosa.filters.mel.

It would be awesome if you fix this issue :)

@EzraApple
Copy link

EzraApple commented Jan 12, 2025

The current code in audio.py that calls librosa.filters.mel :

def _build_mel_basis():
    assert hp.fmax <= hp.sample_rate // 2
    return librosa.filters.mel(hp.sample_rate, hp.n_fft, n_mels=hp.num_mels,
                               fmin=hp.fmin, fmax=hp.fmax)

Newer librosa versions use keyword arguments for sample rate (sr) and number of FFT components (n_fft). A quick fix is replacing it with the following:

def _build_mel_basis():
    assert hp.fmax <= hp.sample_rate // 2
    return librosa.filters.mel(sr=hp.sample_rate, n_fft=hp.n_fft, n_mels=hp.num_mels,
                               fmin=hp.fmin, fmax=hp.fmax)

This is the change in PR #710

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants