The objective is to deploy an audio prediction ML model on Heroku, which uses librosa library from python.
The app.py file uses librosa library to extract features from the audio.
When I try to deploy on Heroku, I get an error as shown below.
2020-06-12T03:27:43.099874+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/librosa/core/audio.py", line 10, in <module>
2020-06-12T03:27:43.099875+00:00 app[web.1]: import soundfile as sf
2020-06-12T03:27:43.099875+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/soundfile.py", line 142, in <module>
2020-06-12T03:27:43.099876+00:00 app[web.1]: raise OSError('sndfile library not found')
2020-06-12T03:27:43.099876+00:00 app[web.1]: OSError: sndfile library not found
2020-06-12T03:27:43.101008+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [11] [INFO] Worker exiting (pid: 11)
2020-06-12T03:27:43.255623+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [4] [INFO] Shutting down: Master
2020-06-12T03:27:43.255725+00:00 app[web.1]: [2020-06-12 03:27:43 +0000] [4] [INFO] Reason: Worker failed to boot.
2020-06-12T03:27:43.333827+00:00 heroku[web.1]: Process exited with status 3
2020-06-12T03:27:43.371190+00:00 heroku[web.1]: State changed from starting to crashed
Here is a snapshot of my buildpacks that I am using to install the dependencies: Build pack list
Below is the list of dependencies mentioned in requirements.txt:
Flask==1.1.1
gunicorn==19.9.0
itsdangerous==1.1.0
Jinja2==2.10.1
MarkupSafe==1.1.1
Werkzeug==0.15.5
numpy>=1.9.2
scipy>=0.15.1
scikit-learn>=0.18
matplotlib>=1.4.3
pandas>=0.19
librosa==0.7.2
aniso8601==8.0.0
audioread==2.1.5
I have also created an Aptfile to install libsndfile1. I have linked a build-pack on Heroku to install from this Aptfile. Below is the list mentioned in my Aptfile:
libsndfile1
libsndfile-dev
libasound2-dev
python-dev
python-numpy
python-setuptools
Here is the image of error "Unable to locate package libsndfile1" while deploying on Heroku
How to overcome the "OSError: sndfile library not found" and "Unable to locate package libsndfile1" errors?
I have uploaded all the files to GitHub here for more information.
Update (12/14/2020): I changed my Aptfile and requirements.txt contents, and it worked.
Here are the contents of Aptfile:
libsndfile1
libsndfile-dev
ffmpeg
Here are the contents of Aptfile:
aniso8601==8.0.0
audioread==2.1.8
certifi==2019.11.28
cffi==1.14.0
Click==7.0
decorator==4.4.2
ffmpeg-python==0.2.0
Flask==1.1.1
Flask-RESTful==0.3.8
future==0.18.2
gunicorn==20.0.4
itsdangerous==1.1.0
Jinja2==2.11.1
joblib==0.14.1
librosa==0.7.2
llvmlite==0.31.0
MarkupSafe==1.1.1
marshmallow==3.2.2
numba==0.48.0
numpy==1.18.1
pycparser==2.20
pydub==0.23.1
pytz==2019.3
resampy==0.2.2
scikit-learn==0.22.2.post1
scipy==1.4.1
six==1.14.0
SoundFile==0.10.3.post1
Werkzeug==1.0.0
wincertstore==0.2
pandas==1.0.1
pathlib==1.0.1