jordipons / musicnn

Pronounced as "musician", musicnn is a set of pre-trained deep convolutional neural networks for music audio tagging.
ISC License
599 stars 87 forks source link

UnboundLocalError: local variable 'batch' referenced before assignment #11

Open inspiralpatterns opened 4 years ago

inspiralpatterns commented 4 years ago

I have been experiencing this error quite often recently and I do not understand what is its main cause. I was looking at this answer but I can not find anywhere else where the variable batch could be created or assigned outside batch_date.

What could be wrong? Python version: 3.7 Traceback is

Computing spectrogram (w/ librosa) and tags (w/ tensorflow).. Traceback (most recent call last):
audio_tagger_1  |   File "main.py", line 95, in <module>
audio_tagger_1  |     suggested_tags = extract_tags(output_filename)
audio_tagger_1  |   File "main.py", line 15, in extract_tags
audio_tagger_1  |     return top_tags(filename, model="MTT_musicnn", topN=10)
audio_tagger_1  |   File "/usr/local/lib/python3.7/site-packages/musicnn/tagger.py", line 60, in top_tags
audio_tagger_1  |     taggram, tags = extractor(file_name, model=model, input_length=input_length, input_overlap=input_overlap, extract_features=False)
audio_tagger_1  |   File "/usr/local/lib/python3.7/site-packages/musicnn/extractor.py", line 158, in extractor
audio_tagger_1  |     batch, spectrogram = batch_data(file_name, n_frames, overlap)
audio_tagger_1  |   File "/usr/local/lib/python3.7/site-packages/musicnn/extractor.py", line 62, in batch_data
audio_tagger_1  |     return batch, audio_rep
audio_tagger_1  | UnboundLocalError: local variable 'batch' referenced before assignment
wtnan2003 commented 3 years ago

Same quesiton Have you sloved it? @inspiralpatterns

shoegazerstella commented 3 years ago

It seems to happen only when the audio file you are trying to load is less than 3 seconds long. Try with an audio of longer duration.