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

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

Open
inspiralpatterns opened this issue Aug 4, 2020 · 2 comments

Comments

@inspiralpatterns
Copy link

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

Same quesiton
Have you sloved it? @inspiralpatterns

@shoegazerstella
Copy link

shoegazerstella commented May 17, 2021

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.

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