Open paulrosen opened 11 months ago
It does the same thing when I drop that file onto https://basicpitch.spotify.com/
Hi @paulrosen , can you provide the audio that you're using? In the future, please use basic-pitch-ts for issues related to the typescript library.
The audio is here: https://production--endearing-hamster-0de147.netlify.app/audio/paul_001.mp3
(With some experimenting, I found that if I shorten the mp3 just slightly it works fine.)
Thanks! Should I close the issue?
Well, it would be nice if the original audio worked. I will be submitting random audio so it will fail periodically. What my workaround looks like is: 1) catch the error 2) shorten the audio by 0.3 seconds 3) retry 4) repeat until it works
The drawback of that is: 1) there is a huge amount of info dumped to the console, which I'd rather not have, 2) redoing the audio will take a little time, so the user will have to wait, 3) there is probably a little bit of extra space at the end of the file, but chopping it off might get rid of part of the last note.
Also, I've tried about 30 recordings so far and 3 of them failed like this, so this isn't a particularly rare case.
If you change the encoding or resample the file does it still fail? Also has it always been files of this length?
I just tried resampling the file to 22050Hz and 44100Hz and converting the file to ogg. I'll take a deeper look.
Note, you could alternatively add 0's to the audio instead of removing the audio. That works at the minimum, but doesn't admittedly solve the root cause.
All the files tend to be different lengths. I didn't see any pattern having to do with file length.
Adding zeros is a better idea for a workaround, thanks!
Here's another example: https://production--endearing-hamster-0de147.netlify.app/audio/mBpJ9URFpMuTXg1HuOaG.mp3
Is there any progress on this? Is there anything I can do to help? I don't know anything about tensorflow so I'm not sure if I could get up to speed.
No progress. I've been a bit busy on #100 and admittedly forgot about this issue. Hopefully, I can get to this issue in a week or two. I do wonder if tfjs has been updated with a fix since you posted this issue. I can check sometime next week.
This sort of issue tends to be an edge case for whenever an audio file is chunked up and processed that way. Most likely, some chunk (probably a trailing chunk) is too small for some part of the code. This is why it doesn't have to do with any specific file length, but instead has to do with multiples of some chunk length with a tail chunk that's too small.
If I catch it I'll see what I can do as well.
I have incorporated
"@spotify/basic-pitch": "1.0.1"
into my website.I'm getting good results from most of my test files, but this one particular file crashes:
https://production--endearing-hamster-0de147.netlify.app/audio/paul_001.mp3
(Note that this URL is good for a while but will eventually go away.)In the console I see:
Then it throws the following error:
Thanks for this amazing library!