Skip to content

murilopolese/acr-cloud

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 acr-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:

identify( buffer )

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

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.

Example

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

About

ACR Cloud library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published