ACR Cloud is a service that provides a cloud solution for audio fingerprinting and recognition. On their SDK and Tools section you can find Android, iOS, Java, Python, C# and C++ libraries.
There is also a web api and that is the one this library is build on top.
This package is available on npm registry:
npm install --save acr-cloud
First of all you have to require and make an instance of ACRCloud
with the correct access key and secret:
var ACRCloud = require( 'acr-cloud' );
var acr = new ACRCloud({
// required
access_key: XXXXX,
access_secret: XXXXX,
// optional
requrl: 'ap-southeast-1.api.acrcloud.com',
http_method: 'POST',
http_uri: '/v1/identify',
data_type: 'audio',
signature_version: '2',
timestamp: Date.now()
});
This instance will provide you 4 methods:
- buffer: Base64 encoded audio file
identify()
is the main method of this module. It will call the methods described below in the correct order and handle all the process, the only thing you have to do is to feed it with the base64 encoded audio file.
This method is a promise and it will resolve itself returning the post
response.
When this method is called it will encrypt the http_method
, http_uri
, access_key
, data_type
, signature_version
and timestamp
using the access_secret
as seed.
This method is a promise and will resolve it with the encrypted value but it will also keep an internal property called string_to_sign
that is the unencrypted values.
- buffer: Base64 encoded audio file
- signature: Encrypted signature generated by
createSignature
This method is a promise that will resolve itself with an object containing the array of parameters to be used on the POST
call and the query generated by this array.
- postData: Object with array of post parameters and it's correspondent query
This method will do nothing but make a POST
request with the postData
and resolve itself returning the POST
response.
There is a working version of this library on the folder example
on this repository. Check it out for more detail.