npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

acr-cloud

0.1.4 • Public • Published

ACR Cloud Node

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.

Installing

This package is available on npm registry:

npm install --save arc-cloud

How to use

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:

createSignature()

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.

createPostData( buffer, signature )

  • 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.

post( postData )

  • 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.

identify( buffer )

  • buffer: Base64 encoded audio file

identify() is the main method of this module. It will call the previous described methods in the right 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.

Example

There is a working version of this library on the folder example on this repository. Check it out for more detail.

Keywords

none

install

npm i acr-cloud

Downloadsweekly downloads

16

version

0.1.4

license

WTFPL

last publish

collaborators

  • avatar
Report a vulnerability