Skip to content

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

Open
tset-tset-tset wants to merge 1 commit intojrgillick:masterfrom
tset-tset-tset:patch-1
Open

Fix: librosa.feature.melspectrogram have argument error#21
tset-tset-tset wants to merge 1 commit intojrgillick:masterfrom
tset-tset-tset:patch-1

Conversation

@tset-tset-tset
Copy link
Copy Markdown

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
Copy Markdown

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

Copy link
Copy Markdown

@nacho-correa nacho-correa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Came here to propose the same changes.

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.

3 participants