An API in Python for generating melody from supplied audio file link.
In order to run this API, you need to install the following software first:
-
/
A route to the homepage
Example using curl command to send GET request in Windows CMD
curl http://melofyapi.ap.ngrok.io
-
/generate
A route to generate melody from supplied audio file link
Example using curl command to send POST request in Windows CMD
curl -i -X POST -H "Content-Type:application/json" -d "{\"audio_file_link\": \"https://melofyapi.blob.core.windows.net/melofy-api-input/twinkle_twinkle_little_star.wav\" }" http://melofyapi.ap.ngrok.io/generate
- Clone GitHub repository
git clone https://github.com/ariessa/melofy-api.git
- Create new conda environment named
snakes
that contains Python 3.7
conda create -n snakes python=3.7
- Activate new environment
conda activate snakes
- Use pip to install packages
pip install audio-to-midi azure-storage-blob flask google-cloud-storage gunicorn magenta timidity
- Run flask app
flask run
Congratulations, you just run the Flask app locally!
- Enable incoming traffic for port
5000
. This is done by navigating to Control Panel> System and Security > Windows Defender Firewall > Advanced Settings
- In Advanced Settings, click on Inbound Rules
- After clicking Inbound Rules, click on New Rules in the Action column
- In New Inbound Rule Wizard, select Rule Type as Port and click Next
- In New Inbound Rule Wizard, apply rule to TCP and set specific local port to 5000 and click Next
- In New Inbound Rule Wizard, specify action to Allow the connection and click Next
- In New Inbound Rule Wizard, specify profile for which rule applies to Private
- Still in New Inbound Rule Wizard, specify name to Melofy API Port 500 and description to Allow inbound connection to local port 5000 using private connection and click Finish
- Check New Inbound Rule in the list of Inbound Rules
Congratulations, you just exposed local port 5000 to the Internet!
Basic Command
Expose a web server on port 5000 of your local machine to the Internet
ngrok http 5000
Advanced Commands
Expose a web server on port 5000 of your local machine to the Internet, set region to Asia Pasific, and subdomain to melofyapi
ngrok http -region=ap -hostname=melofyapi.ap.ngrok.io 5000
Congratulations, you can now access the API at http://melofyapi.ap.ngrok.io
!