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

Colab Notebook example cannot be run #578

Open
isold23 opened this issue Nov 3, 2023 · 10 comments
Open

Colab Notebook example cannot be run #578

isold23 opened this issue Nov 3, 2023 · 10 comments

Comments

@isold23
Copy link

isold23 commented Nov 3, 2023

Colab Notebook example cannot be run
error message:
Using cuda for inference. Reading video frames... Number of frames available for inference: 210 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
why && how to fix?

@sahreen-haider
Copy link

Colab Notebook example cannot be run
error message:
Using cuda for inference. Reading video frames... Number of frames available for inference: 210 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
why && how to fix?

lets debug the error:
The above is a TypeError: indicating librosa.filter.mel() got 0 positional arguments are given, which indeed aren't needed.
going to audio.py line 100, the arguments are there for a specific purpose like for sampling rate, The number of samples used in each block for the Fourier transform, The number of Mel filters to generate, The lowest frequency (in Hz) of the Mel filters, The highest frequency (in Hz) of the Mel filters.
The below code does which is throwing the error looks something like the below.
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)
But as far as I can make a sense of it the code is pretty legit and shouldn't be raising an error,
Now navigating through several files and looking through a bunch of code,
what I can guess is the format expected here is 'wav' for audio.
So please look for the audio format that your are using, if the audio is not 'wav' then it needs to be changed.

@isold23
Copy link
Author

isold23 commented Nov 5, 2023

Thank you for your reply. The problem was solved by lowering the version of librosa, but a new problem appeared. The installation of the lower version of numba failed, and the following interface incompatibility problem occurred with the higher version of numba. how should I solve this?
Traceback (most recent call last): File "/content/Wav2Lip/inference.py", line 3, in <module> import scipy, cv2, os, sys, argparse, audio File "/content/Wav2Lip/audio.py", line 1, in <module> import librosa File "/usr/local/lib/python3.10/dist-packages/librosa/__init__.py", line 13, in <module> from . import core File "/usr/local/lib/python3.10/dist-packages/librosa/core/__init__.py", line 114, in <module> from .time_frequency import * # pylint: disable=wildcard-import File "/usr/local/lib/python3.10/dist-packages/librosa/core/time_frequency.py", line 10, in <module> from ..util.exceptions import ParameterError File "/usr/local/lib/python3.10/dist-packages/librosa/util/__init__.py", line 73, in <module> from . import decorators File "/usr/local/lib/python3.10/dist-packages/librosa/util/decorators.py", line 9, in <module> from numba.decorators import jit as optional_jit ModuleNotFoundError: No module named 'numba.decorators'

@sahreen-haider
Copy link

Thank you for your reply. The problem was solved by lowering the version of librosa, but a new problem appeared. The installation of the lower version of numba failed, and the following interface incompatibility problem occurred with the higher version of numba. how should I solve this?
Traceback (most recent call last): File "/content/Wav2Lip/inference.py", line 3, in <module> import scipy, cv2, os, sys, argparse, audio File "/content/Wav2Lip/audio.py", line 1, in <module> import librosa File "/usr/local/lib/python3.10/dist-packages/librosa/__init__.py", line 13, in <module> from . import core File "/usr/local/lib/python3.10/dist-packages/librosa/core/__init__.py", line 114, in <module> from .time_frequency import * # pylint: disable=wildcard-import File "/usr/local/lib/python3.10/dist-packages/librosa/core/time_frequency.py", line 10, in <module> from ..util.exceptions import ParameterError File "/usr/local/lib/python3.10/dist-packages/librosa/util/__init__.py", line 73, in <module> from . import decorators File "/usr/local/lib/python3.10/dist-packages/librosa/util/decorators.py", line 9, in <module> from numba.decorators import jit as optional_jit ModuleNotFoundError: No module named 'numba.decorators'

I think these error's are rising due to incompatibility issues.

- So trying previous builds of python might help, rather than using python 3.10.

@isold23
Copy link
Author

isold23 commented Nov 5, 2023

If you lower the python version to 3.8, pip cannot be installed, and the example still cannot be run. colab cannot install python3.6.

@sahreen-haider
Copy link

If you lower the python version to 3.8, pip cannot be installed, and the example still cannot be run. colab cannot install python3.6.

is there anyway you can try to run it on your local machine.

@davidkundrats
Copy link

Colab Notebook example cannot be run error message: Using cuda for inference. Reading video frames... Number of frames available for inference: 210 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 why && how to fix?

Which colab are you running?

@isold23
Copy link
Author

isold23 commented Nov 23, 2023

Colab Notebook example cannot be run error message: Using cuda for inference. Reading video frames... Number of frames available for inference: 210 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 why && how to fix?

Which colab are you running?

https://colab.research.google.com/drive/1tZpDWXz49W6wDcTprANRGLo2D_EbD5J8?usp=sharing

@Leungsiuyin
Copy link

Leungsiuyin commented Jan 16, 2024

After reading librosa Doc https://librosa.org/doc/latest/generated/librosa.filters.mel.html
We can change the code in audio.py line 100 to : return librosa.filters.mel(sr=hp.sample_rate, n_fft=hp.n_fft, n_mels=hp.num_mels, fmin=hp.fmin, fmax=hp.fmax)

@Arslan-Mehmood1
Copy link

Arslan-Mehmood1 commented Jan 18, 2024

To all those facing : No module named 'numba.decorators'

set librosa version to 0.9.0. and numba = 0.58.1

Colab - Python 3.10.12
Date - Jan 18 2024

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

6 participants
@isold23 @Leungsiuyin @Arslan-Mehmood1 @sahreen-haider @davidkundrats and others