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

Fix: librosa.feature.melspectrogram have argument error #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tset-tset-tset
Copy link

Hi jrgillick,

Now I tried to run it on the following notebook, but it was giving me errors, so I checked the cause.

See https://github.com/tset-tset-tset/hoge/blob/master/laughter-detection-interactive.ipynb for more information.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-d786ed2041b6> in <cell line: 14>()
     12 ##### Load the audio file and features
     13 
---> 14 inference_dataset = data_loaders.SwitchBoardLaughterInferenceDataset(
     15     audio_path=audio_path, feature_fn=feature_fn, sr=sample_rate)
     16 

/content/laughter-detection/./utils/data_loaders.py in __init__(self, audio_path, feature_fn, sr, n_frames)
    189 
    190         self.y, _ = librosa.load(audio_path, sr=sr)
--> 191         self.features = feature_fn(y=self.y,sr=self.sr)
    192 
    193     def __len__(self):

/content/laughter-detection/./utils/audio_utils.py in featurize_melspec(f, offset, duration, y, sr, hop_length, augment_fn, spec_augment_fn, **kwargs)
    226     if augment_fn is not None:
    227         y = augment_fn(y)
--> 228     S = librosa.feature.melspectrogram(y, sr, hop_length=hop_length).T
    229     S = librosa.amplitude_to_db(S, ref=np.max)
    230     if spec_augment_fn is not None:

TypeError: melspectrogram() takes 0 positional arguments but 2 positional arguments (and 1 keyword-only argument) were given

The error is not only happening when running from the notebook, but also when running segment_laughter.py script.

I think this fix will fix the error. Could you please check?

@GitSimply
Copy link

replace line 228 of /content/laughter-detection/./utils/audio_utils.py with this:
S = librosa.feature.melspectrogram(y=y, sr=sr, hop_length=hop_length).T

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

Successfully merging this pull request may close these issues.

2 participants