This example app showcases how you can integrate the Cyanite.ai API into your own application.
Before getting started you will need to create an integration over at https://app.cyanite.ai/integrations
You need the following:
- Access Token
- Webhook Secret
After receiving these copy .env.sample
to .env
and adjust the values.
Then you can install the dependencies using either yarn install
(or npm install
).
The script uses ngrok.io
for exposing the port to the internet. This allows to make the webhook accessible from the Cyanite.ai servers for development purposes. In production environment you should not rely on ngrok.io but rather have a public facing server/service.
run yarn proxy-port
(npm run proxy-port
)
Wait until you see the following output (in case your port is already in use you will have to configure the port inside your .env
file.)
yarn run v1.15.2
$ node src/proxy-port.js
Server listening on https://f288XXXX.ngrok.io/incoming-webhook
Copy the ngrok.io url and update your Cyanite.ai Integration Webhook Url to the given value. (You can use the test button to ensure that the requests arrive).
Please keep the proxy-port running.
run yarn start
(or npm start
)
Run the src/file-upload.js
script using yarn file-upload
(or npm run file-upload
).
yarn file-upload "./piano-sample.mp3"
Run the src/file-enqueue-analysis.js
script using yarn file-enqueue-analysis
(or npm run file-enqueue-analysis
).
The script will enqueue a file analysis. After a few seconds you should be able to see some output in the terminal of the webhook server.
yarn file-enqueue-analysis "<put-analysis-id-here>"